problem about content-script-Collection of common programming errors
Uri
javascript google-chrome-extension content-script
I have a chrome content script running on a few pages, with a console.log (and nothing else). I’ve noticed that on one page the script doesn’t run (no console output). The only thing different about this page is that its original code runs with an error. Can this be the reason the content script does not run on this page?Is there a way to make it run in spite of the error?
Brock Adams
jquery google-chrome-extension content-script
As mentioned in chrome extension development tutorial I can include jQuery in my manifest.json file to use it in a content script like so:”content_scripts”: [{“matches”: [“http://www.google.com/*”],”css”: [“mystyles.css”],”js”: [“jquery.js”, “myscript.js”]}],I did that. But when I open the javascript console and click on the browser action icon of my extension, I see the error: “Uncaught ReferenceError: $ is not defined”.What should I have to do!? I can’t understand what’s wrong.Updates from OP,
tempcode
javascript google-chrome google-chrome-extension content-script
I want to let the user decide when they want to run a script, so that when the browser opens, the “off” icon is showing and no script runs; but when the user clicks it, it changes to an “on” icon and executes a userscript, until the user clicks off. I have two png icons which are 32×32 each: on.png and off.png.My two questions:How can I set the default icon to my off.png? I tried this in my manifest.json but it didn’t set the icon, instead showed a puzzle piece (I presume a default):… “browser
user1335906
firefox-addon firefox-addon-sdk content-script
I created an add-on using add-on builder. I attached a content-script to the pageMod in main.jsMy content script counts the number of dynamic tags created using document.createElement(). This is done by creating a hook to document.createElement() and added this function to webpage by creating a script tag. My code is as follows.contentscriptFile:addJS_Node (“var count=0;”); function LogDocCreateElement () {var oldDocumentCreateElement = document.createElement; document.createElement = function
Rob W
google-chrome-extension content-script
In my extension I need to transfer some data from one tab’s content script to another tab’s content script. How can I choose certain tab using chrome.tabs, if I know a part of that tab object’s name or url in it? How can two tabs’ scripts communicate?UPDATE:Apparently I don’t have method sendMessage in chrome.extension. When I run the following from content script: chrome.extension.sendMessage(“message”);I get in console:Uncaught TypeError: Object # has no method ‘sendMessage’
Morgan
google-chrome background messaging content-script
Let me explain the problem. I’m developping a chrome extension and I’m stuck with a little functionnality. I need to grab the url in the browser and retrieve something from my server to update the badgeText.contentscript1.jschrome.extension.sendMessage({method:”sendUrlInBrowser”,urlinbrowser: location.href}, function(response) { });contentscript2.jschrome.extension.sendRequest({method: “getInfosUser”}, function(response) { var url = location.href; var id_user = response.id_user; var default_frie
Ali Esmailian
google-chrome google-chrome-extension content-script
I have created script.js with content_script.js to add button to a pageContent_script.jsvar s = document.createElement(‘script’); s.src = chrome.extension.getURL(“script.js”); s.onload = function () {this.parentNode.removeChild(this); }; (document.head || document.documentElement).appendChild(s); and in script.js add button with onclick event.var someDive = document.getElementsByClassName(“someClass”)[0]; var button = document.createElement(“button”); button.setAttribute(“onclick”, “doSomeThing(
Brock Adams
javascript jquery jquery-plugins google-chrome-extension content-script
I have a small JavaScript file based in JS/jQuery and an additional library. It is running perfectly as independent files, but I am having problems getting it up and running in a Chrome extension.The script checks each image of an HTML page for specific characteristics, and depending on that adds a border around the image.manifest.json{“name”: “ImageId”,”version”: “0.1”,”manifest_version”: 2,”browser_action”: {“default_icon”: “icon.png”},”content_scripts” : [{“matches” : [“http://*/*”,”https://
FractalBob
javascript google-chrome-extension content-script
My extension is supposed to load a content script, searchTopic.js, only after the page it’s injected into has already fully loaded (yes, I have set “run_at” to “document_end” in the extension manifest), but in fact it’s loading before all the DOM objects have been created (the crucial ones are created via some Javascript in the page). So, the question is, how can I wait until the page’s Javascript has executed? Here’s my manifest:”content_scripts”: [{“run_at”: “document_end”,”matches”: [“https:/
Rob W
javascript google-chrome-extension content-script
I’m trying to inject a function into a webpage via Chrome extension content script by:function inject(code) {var actualCode = ‘(‘ + code + ‘)();’;var script = document.createElement(‘script’);script.textContent = actualCode;(document.head||document.documentElement).appendChild(script);script.parentNode.removeChild(script); }var myObj = person; // myObj/person is passed in from elsewhere var fn = function() {alert(myObj.name); }; inject(fn); // myObj undefinedMy issue is, since fn is a function
Camilo Martin
javascript jquery google-chrome google-chrome-extension content-script
I can’t manage to load jQuery in a Google Chrome userscript.This is how my manifest.json looks:{//…”content_scripts” : [{“js” : [“http://code.jquery.com/jquery-1.7.1.js”, “code.js”],//…}],//… }But in code.js, $ is undefined.code.js otherwise works, and actually I have a bookmarklet working (that uses the site’s version of jQuery).I’ve tried minified and unminified versions of jQuery, hosted or local.I’ve also tried embedding a minified jQuery at the top of my code.js, but if I do that the
Brock Adams
javascript google-chrome userscripts content-script
I’m trying to change the variable in a page using a userscript. I know that in the source code there is a variable var smilies = false;In theory I should be able to change it like that:unsafeWindow.smilies = true;But it doesn’t work. When I’m trying to alert or log the variable to the console without hijacking I get that it’s undefined.alert(unsafeWindow.smilies); // undefined !!!EDIT: I’m using Chrome if it changes anything…http://code.google.com/chrome/extensions/content_scripts.html says:Co
user1070827
iframe google-chrome-extension content-script
i want to make a chrome extension on google reader and i found a problem. content script can not access to iframes. For all n, window.frames[n] = undefined. And i have this “all_frames”: true in manifest.json. Or someone could tell me how to add a button under each article. Thank you!
vikkun
google-chrome google-chrome-extension inject content-script
I am asking this question after looking at several related questions on stackoverflow. I started with how to detect if an extension is installed. I opted for the method where I add a div to body using content scripts on some pages. Here is how I did it…manifest.json{“name”: “Install Check”,”content_scripts”: [{“matches”: [“http://host.com/*”],”js” : [“insert_node.js”]}],”permissions”: [“tabs”, “host.com/*”] }insert_node.js (content script)var insert_node = document.createElement(‘div’); insert
Web site is in building