chrome.windows.create not working in Tor extension - tor

I've written an add-on / extension for the Tor browser. As we know, Tor is equivalent to Firefox. So, the extension I created works like a charm in Firefox, but in Tor, not so good.
So, this is what I'm trying to do inside the background script:
chrome.windows.create({
url: `popup.html`,
type: 'popup',
height: 800,
width: 900
});
In Tor, the popup is opened, but remains black/empty, nothing is happening inside the window
Here is my manifest.json
{
"name": "Tor test",
"version": "0.0.0",
"description": "Extension",
"manifest_version": 2,
"permissions": [
"background",
"storage",
"unlimitedStorage",
"*://*/*"
],
"browser_action": {
"default_icon": "icon-off-128.png"
},
"background": {
"scripts": ["background.js"]
},
"content_scripts": [
{
"matches": ["<all_urls>"],
"run_at": "document_idle",
"js": ["content.js"]
}
],
"web_accessible_resources": [
"popup.html"
],
}
Any suggestions why the popup doesn't display any content inside that popup?

Related

Not running at document_start

My extension doesn't run at document_start. The manifest.json:
{
"manifest_version": 3,
"name": "Lift Web Restrictions",
"description": "Simple extension that removes most ads, web restrictions, adds mods to MooMoo.io / Krunker.io / and more!",
"version": "0.0.5",
"icons": {
"16": "logo/sw16.png",
"48": "logo/sw48.png",
"128": "logo/sw128.png"
},
"permissions": [],
"host_permissions": [
"*://*/*"
],
"background": {
"service_worker": "service-worker.js"
},
"web_accessible_resources": [
{
"resources": ["modules/script.js"],
"matches": ["*://*/*"]
}
],
"content_scripts": [{
"js": [
"modules/transfer.js"
],
"matches": ["http://*/*", "https://*/*"],
"all_frames": true,
"run-at": "document_start"
}]
}
There's a console.log within modules/transfer.js, however the page's script tag beats it.
Launching egAps
index.bf049c93.js?52f6f7bb66295262766e:2 Downloading d.js...
index.bf049c93.js?52f6f7bb66295262766e:2 Loading WASM c66eb3cbd8fdc1325900.wasm
^^^^ logged before script runs
index.bf049c93.js?52f6f7bb66295262766e:2 1 dependencies left
transfer.js:1 fireAt <--- where it runs
index.bf049c93.js?52f6f7bb66295262766e:2 0 dependencies left
index.bf049c93.js?52f6f7bb66295262766e:2 Running...
index.bf049c93.js?52f6f7bb66295262766e:2
Replace run-at with run_at
Thank you wOxxOm

Chrome Extension - need to add chrome.browser actions in content scripts

So basically I need to do a couple of things
chrome.webrequests.onBeforeRequest.addlisteners
chrome.browser.addbadgetext
chrome.tabs.query
in a content script. The reason why I want this in content script is because I want the above to trigger without clicking the extension icon on the active page. How can I do that?
Below is my manifest.json
{
"manifest_version": 2,
"name": "My Ext",
"description": "My Ext desc",
"icons": {
"16":"logo-sm.png",
"48":"logo-sm.png",
"128":"logo-sm.png"
},
"version": "1.0",
"homepage_url": "abc.com",
"browser_action": {
"default_icon": "favicon.png",
"default_title": "My ext"
},
"background": {
"scripts": ["scripts/background.js"],
"persistent": true
},
"web_accessible_resources": ["oxy-logo-sm.png"],
"content_scripts": [{
"matches": ["<all_urls>"],
"all_frames": true,
"js":["scripts/content.js"],
"run_at": "document_start"
}],
"permissions": ["activeTab", "webRequest", "tabs", "<all_urls>"]
}

Chrome manifest "run_at": "document_end" not working when navigating

I have the following manifest to run on every page load.
The problem is that it is running only when refreshing the page.
The myscript.js will not work when I click on a link and navigate, again, only on refresh.
Why is that?
Thanks
{
"name": "BrowserActionExtension",
"version": "0.0.1",
"manifest_version": 2,
"browser_action": {
"default_title": "That's the tool tip",
"default_popup": "popup.html"
},
"content_scripts": [
{
"matches": [ "<all_urls>" ],
"js": [ "myscript.js" ],
"run_at": "document_end"
}
],
"permissions": [
"tabs",
"<all_urls>"
]
}
If the page contains frames and the link on which you click does not belong to the top frame you get this behaviour.
Take a look to all_frames
This value is always false, but if you set this to true the script is injected in all frames.

Chrome.windows.create not working

In my content script I do
chrome.windows.create({url: "local.html", type: "popup"});
however, no window ever shows up.
Do I need to change my manifest file first? Why doesn't this function create a new window ever?
I have tabs enabled like so
{
"name": "Tool",
"version": "0.0.1",
"manifest_version": 2,
"description": "",
"homepage_url": "",
"icons": {
"16": "icons/on.png",
"48": "icons/on.png",
"128": "icons/on.png"
},
"default_locale": "en",
"background": {
"page": "src/bg/background.html",
"persistent": true
},
"browser_action": {
"default_icon": "icons/on.png",
"default_title": "browser action demo"
},
"permissions": [
"<all_urls>","tabs", "webNavigation"
],
"content_scripts": [
{
"run_at": "document_end",
"matches": [
"<all_urls>"
],
"js": [
"src/lib/jquery.min.js", "src/inject/inject.js"
],
"css": [
"src/inject/inject.css"
]
}
]
}
You are trying to call this from the content script.
Quoting the docs:
However, content scripts have some limitations. They cannot:
Use chrome.* APIs (except for parts of chrome.extension)
If you need to initiate some action that uses Chrome API from the content script, you have to message your background script to do this. See Architecture overview and Messaging.

Cannot read property 'onConnet'

I'm attempting to follow the documentation here to pass a variable from my background script, to my content script.
http://code.google.com/chrome/extensions/messaging.html
Manifest:
{
"name": "name",
"description": "desc",
"version": "1.0",
"manifest_version": 2,
"content_scripts": [
{
"matches": [ "http://*/*", "https://*/*" ],
"js": ["content.js"]
}
],
"background": {
"scripts": ["background.js"]
},
"permissions": [
"tabs",
"http://*/*",
"https://*/*"
],
"options_page": "options.html",
"browser_action":
{
"default_icon": "icon.png",
"default_title": "Settings",
"default_popup": "settingspanel.html"
}
}
background.js file:
chrome.extension.onConnect.addListener(function(port) {
port.onMessage.addListener(function(msg) {
port.postMessage({counter: msg.counter+1});
});
});
content.js
chrome.extension.onRequest.addListener(
function(request, sender, sendResponse) {
sendResponse({counter: request.counter+1});
});
I receive an error on the background script that says "Cannot read property 'onConnect' of undefined"
Probably your problem is Issue #131623: Reloading extension while developer tools are open breaks chrome object and js console.
Until the fix gets through you have to close the Developer Tools before reloading the extension.

Resources