Extension Help?

28 views
Skip to first unread message

Jake Messing

unread,
Oct 15, 2017, 6:09:45 PM10/15/17
to Chromium-Extensions-Announce
I'm working on creating an extension that opens chrome://restart so that i can quickly restart the browser. i am pretty sure that i want it in a new tab but it dost seem to be working. I'm fairly new to this. I have two different versions and i'm not sure what to use.

{
  "manifest_version": 2,

  "name": "Restart",
  "description": "A quick way to restart your Chrome browser.",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
"default_title": "Restart"

  },
  
  "permissions": [
    "activeTab",
"tabs"
  "background": {
"scripts": ["background.js"]

   chrome.tabs.create(object createProperties, function callback)
  );
);
  ]
}

or this 

{
  "manifest_version": 2,

  "name": "Restart",
  "description": "A quick way to restart your Chrome browser.",
  "version": "1.0",

  "browser_action": {
    "default_icon": "icon.png",
"default_title": "Restart"

  },
  
  "permissions": [
    "activeTab",
"tabs"
  "background": {
"scripts": ["background.js"]

chrome.browserAction.onClicked.addListener(function(tab) {
    chrome.tabs.query({active: true, currentWindow: true}, function(tabs) {
    var activeTab = tabs[0];
    chrome.tabs.sendMessage(activeTab.id, {"message": "clicked_browser_action"});
chrome.runtime.onMessage.addListener(
    function(request, sender, sendResponse) {
    if( request.message === "open_new_tab" ) {
      chrome.tabs.create({"url": chrome://restart});
  );
);
  ]
}

PhistucK

unread,
Oct 16, 2017, 12:30:20 AM10/16/17
to Jake Messing, Chromium-Extensions-Announce
I guess you mixed manifest.json code and background.js code for brevity?

Content scripts cannot use chrome.tabs and you are sending a message to a content script (that you did not define) and listen to that message in the background page - it will never reach it.

In your first example, there is not real code, just the signature of chrome.tabs.create.


PhistucK

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.
Visit this group at https://groups.google.com/a/chromium.org/group/chromium-extensions/.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-extensions/18f2b352-049b-4b64-be41-0f45c5116e46%40chromium.org.
For more options, visit https://groups.google.com/a/chromium.org/d/optout.

Jake Messing

unread,
Oct 16, 2017, 3:07:48 AM10/16/17
to Chromium-Extensions-Announce, yaakov...@gmail.com
Okay so are you able to help me out with the code?


PhistucK

To post to this group, send email to chromium-...@chromium.org.

PhistucK

unread,
Oct 16, 2017, 3:34:30 AM10/16/17
to Jake Messing, Chromium-Extensions-Announce
I would expect chrome.tabs.create({url: "chrome://restart"}); to work. If it does not work, then I guess Chrome is intentionally blocking this.


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.

Jake Messing

unread,
Oct 16, 2017, 3:42:31 AM10/16/17
to Chromium-Extensions-Announce, yaakov...@gmail.com
Attached is what I have. Are you able to see whats going on and why it dosnt work?


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
manifest.json

PhistucK

unread,
Oct 16, 2017, 3:59:54 AM10/16/17
to Jake Messing, Chromium-Extensions-Announce
Your manifest is wrong.
manifest.json cannot contain code. It is a JSON file.
background.js should contain this code. Did you try to load/run your extension at all? It would not work as it stands.


PhistucK



PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsubscribe...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "Chromium-Extensions-Announce" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
To post to this group, send email to chromium-extensions@chromium.org.

Devlin Cronin

unread,
Oct 16, 2017, 1:19:17 PM10/16/17
to Chromium-Extensions-Announce, yaakov...@gmail.com
Unfortunately, Chrome does block this.  See crbug.com/508192.


PhistucK



PhistucK

To unsubscribe from this group and stop receiving emails from it, send an email to chromium-extensions+unsub...@chromium.org.
Reply all
Reply to author
Forward
0 new messages