content-script

Firefox Addon - Accessing pre-loaded content script from ActionButton

柔情痞子 提交于 2019-12-06 11:32:37
I am attaching content script to every tab on my firefox add-on. And if user clicks on ActionButton (top right icon on browser) I am trying to access content script handler function, but it does not work. I am using walkthroughs from Content Scripts but still could not make it work. Am I doing something wrong? Please see code below the TODO marked areas are not working; // main.js tabs.on('ready', function (tab) { var worker = tab.attach({ include: "*", //contentScript: 'window.alert("Page matches ruleset");', contentStyleFile: [data.url("scripts/myTestContent1.js")] }); worker.port.on(

Loading a local html file in an injected iframe within a firefox extension

风流意气都作罢 提交于 2019-12-06 10:25:39
问题 I'm currently developping a firefox extension which basically insert an iframe in the current page when the user click on the extension icon. I managed to insert the iframe code, I figured out how to link the src attribute to my html file. In the chrome version, I simply do a var main_html = chrome.extension.getURL('main.html'); And I pass the link to the src attribute of the iframe like that : iframe.setAttribute("src",main_html); So main_html is a link like resource://idofmyextension

one more time about: Error: Attempting to use a disconnected port object, how to?

不想你离开。 提交于 2019-12-06 08:14:54
here is my setup background.js var port = null; function setPort() { chrome.tabs.query({active: true, currentWindow: true}, function (tabs) { port = chrome.tabs.connect(tabs[0].id, {name: "CONTENTSCRIPT"}); }); } // when i click on something, get the port and send a message function clickHandler(e) { setPort(); if (port) { port.postMessage({key: 'message', value: true}); } } contentscript.js chrome.runtime.onConnect.addListener(function (port) { if (port.name == "CONTENTSCRIPT") { port.onMessage.addListener(function (msg) { console.log(msg); }); } }); what i am doing is clicking on a

I set geolocation permission in the manifest, but every page still asks to share location

99封情书 提交于 2019-12-06 06:34:33
I'm using a content-script in a chrome extension that I'm writing. I included geolocation in my list of permissions, but on every webpage I still get asked if I want to share my location. I thought if I set geolocation in the list of permissions, I would avoid this? Here's the relevant code from my manifest.json : "permissions": ["geolocation"], "content_scripts": [ { "matches": ["<all_urls>"], "js": ["main.js"] } ] And how I'm using it: navigator.geolocation.getCurrentPosition(function(position) { console.log("latitude=" + position.coords.latitude + ", longitude=" + position.coords.longitude)

Firefox extension is sending Javascript Array as an Object instead

若如初见. 提交于 2019-12-05 22:06:07
I have problem passing JavaScript arrays to an Add-On, which I'm writing in Add-on Builder . To communication I'm using events and sending an event with an array, but the Add-on (Content Script) gets an object, not an array. This is event: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <script src="http://code.jquery.com/jquery-latest.min.js" type="text/javascript"></script> <script type=

Unable to view content script references in the developer tools window

回眸只為那壹抹淺笑 提交于 2019-12-05 09:08:30
When I view my extension with the developer tools, I only see the generated background file, background.js; my content script doesn't appear under the content scripts tab. Any ideas why? The relevant part of the manifest looks like this: "content_scripts": [{ "run_at": "document_end", "js": ["postMsg.js"], "matches": ["https://groups.google.com/forum/*"] }], postMsg.js gets injected into the page, but never appears in the developer tool window, so I'm unable to debug it. Brock Adams As long as you are on a page that matches the "Match patterns and globs" from your manifest, you will see the

Dynamic loading of content script (chrome extension)

蹲街弑〆低调 提交于 2019-12-05 04:51:35
I have an chrome extension, with 2 content script injected by manifest and one background script. { "manifest_version": 2, "name": "Test", "permissions": [ "tabs", "<all_urls>", "activeTab", "storage" ], "content_scripts": [ { "matches": ["http://*/*", "https://*/*"], "js": [ "content/autofill/lib_generic.js", "content/autofill/lib.js"], "run_at": "document_end" } ], "web_accessible_resources": [ "content/specific_scripts/*" ], "background": { "scripts": ["background.js"], "persistent": false } } lib_generic.js contains one function named apply_forms(...) (its description is not important).

Javascript not always working in Chrome Extension, when should I run it?

拥有回忆 提交于 2019-12-05 02:22:57
问题 I have a Chrome Extension which is injecting both CSS and Javascript into the page, and while the CSS is always being injected, the Javascript is only working sometimes and not others. By not working, I assume it's running before the stuff exists that it has to deal with. The Javascript is simply moving a div above another using insertBefore but this isn't always happening, and I assume it's because of when it's loading. My manifest is currently: { ... "content_scripts": [{ "matches": [ "*:/

Loading a local html file in an injected iframe within a firefox extension

吃可爱长大的小学妹 提交于 2019-12-04 16:58:31
I'm currently developping a firefox extension which basically insert an iframe in the current page when the user click on the extension icon. I managed to insert the iframe code, I figured out how to link the src attribute to my html file. In the chrome version, I simply do a var main_html = chrome.extension.getURL('main.html'); And I pass the link to the src attribute of the iframe like that : iframe.setAttribute("src",main_html); So main_html is a link like resource://idofmyextension/content/data/main.html But, as I suspected, I get a security error telling me that the content located at the

Chrome Extension - Injected Iframe not accessing Chrome browserAction or chrome.tabs or AngularJS

陌路散爱 提交于 2019-12-04 16:16:31
I have a chrome extension that toggles a sidebar with the browser action click. The sidebar contains an iframe with a local (chrome extension) source. I thought the page within the iframe would be considered a local chrome extension file with open access to the chrome APIs and etc. However, I keep getting the following errors in the web console: Uncaught TypeError: Cannot read property 'onClicked' of undefined <-- background.js TypeError: Cannot read property 'query' of undefined <-- sidebar.js How do I get it so that the iframe injected with a context script has access to the local chrome