content-script

Chrome extension run at doc start

眉间皱痕 提交于 2019-12-11 07:36:45
问题 I have a script that I want to be injected into the document BEFORE load. I.E; it should function as if <script..>MYSCRIPT HERE</script> <html> . . I have made a script in chrome that executes correctly (I can alert(0) etc) but, it runs in different environment which is not what I want. I want it to run in the SAME environment as page. Earlier, I had used a trick where in the startup script I had used window.location="javascript:<MY SCRIPT HERE>" which effectively changes the execution

Issues with using an iframe to show chrome extension UI on a web page?

梦想的初衷 提交于 2019-12-11 03:04:23
问题 I am developing a chrome extension that is meant to work on all web pages. As part of its functionality, it needs to show a UI on any given page. Currently, to do this, I append a div (containing the UI HTML) to the page from the content script. The issue with this is that the styles of the containing page get applied to the extension's UI, causing it to look different on different webpages. Two approaches to fixing this issue: Apply specific styles (marked as !important) for the extension's

Simple Chrome Content Script Not Running

大城市里の小女人 提交于 2019-12-10 22:44:28
问题 I wrote a short content script, which stops a particular site from creating new windows for link clicks. This is my first Chrome extension, and I've scored this website and the internet for a reason why it won't run, but I can't find any. I'm probably making a fundamental amateur mistake somewhere. Manifest.json: { "manifest_version": 2, "name": "DHS Links", "description": "Stops the school's site from constantly opening new windows.", "version": "1.0", "browser_action": { "default_icon":

Why won't the SVG load in chrome extension?

懵懂的女人 提交于 2019-12-10 11:14:55
问题 I am injecting some HTML into websites using a chrome extension. In that code I am including an SVG. But when I load websites I get Failed to load resource: the server responded with a status of 404 (Not Found) http://stackoverflow.com/questions/SVG/home-outline.svg All of my svg files are in a folder called SVG. I am loading the SVG files with "web_accessible_resources": ["SVG/*.svg"] as I have loaded my other files. Why won't my image load? <span class="menu_T"> <button class="large_menu

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

帅比萌擦擦* 提交于 2019-12-10 10:49:16
问题 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

Selecting <option> of a <select> from a chrome extension content script

烂漫一生 提交于 2019-12-09 06:31:51
问题 I'm hoplessly trying to activate a change() event from a chrome content script. I've gone past through of the website and google posts, but still nothing works. here's a description of what i'm tryin to achieve consider the following webpage (reachable via http://www.gilzu.com/TFF/select.html should someone be so kind to help) : <html xmlns="http://www.w3.org/1999/xhtml" > <head> <title>Untitled Page</title> <script type="text/javascript" src="jquery.js"></script> <script type="text

Injecting content script in dynamically created iframe

倾然丶 夕夏残阳落幕 提交于 2019-12-07 19:30:22
问题 I have a chrome extension, with content script 1 which programmatically creates an iframe (not same domain iframe) on the current page. I want to run a content script 2 of my chrome extension inside this new iframe (e.g. when a user clicks on something inside the iframe, a message is sent to the background script). In my manifest.json, I added in the content scripts section: { "matches": ["http://url_of_my_new_iframe/*"], "css": [], "js": ["ContentScript2.js"], "run_at": "document_idle", "all

Firefox extension is sending Javascript Array as an Object instead

北城以北 提交于 2019-12-07 12:08:25
问题 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">

Can I use an external array to match URLs for content script injection?

杀马特。学长 韩版系。学妹 提交于 2019-12-06 12:53:05
I'm working on a chrome extension where I'd like to inject a content script into a list of urls. Usually I'd use the regular syntax: { "name": "My extension", ... "content_scripts": [ { "matches": ["http://www.google.com/*"], "css": ["mystyles.css"], "js": ["jquery.js", "myscript.js"] } ], ... } But for the match patterns I'd like to pull the array from a server. Is there a way to programmatically set the "matches" array (from the background.js file for example)? Iván Nokonoko As far as I know, you cannot modify your manifest.json file from within the extension. What you can do is

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

試著忘記壹切 提交于 2019-12-06 12:04:11
问题 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