content-script

Chrome Extension API: chrome.tabs.captureVisibleTab on Background Page to Content Script

丶灬走出姿态 提交于 2019-12-20 03:05:07
问题 My overall goal was to take a screenshot via the background page using: http://developer.chrome.com/extensions/tabs.html#method-captureVisibleTab and pass it to the content script so I can use the page's HTML DOM to analyze the screenshot and cut it up the way I would like. However, I can't seem to pass the dataUrl back to the content script with Message Passing: http://developer.chrome.com/extensions/messaging.html I tried JSON.stringify() but to no avail. This works perfectly fine:

Why is chrome.cookies undefined in a content script?

早过忘川 提交于 2019-12-18 16:11:06
问题 Whenever I try to read from a cookie using the chrome.cookies.get() function I get this error: TypeError: Cannot read property 'get' of undefined. I am calling the function in my content.js file, and it will only run on twitter.com(that part works). Here is my manifest file: { "manifest_version": 2, "name": "Twitter-MultiSignin", "description": "twiter sign in", "version": "1.0", "permissions": [ "cookies", "alarms" , "http://*/*", "https://*/*", "storage"], "content_scripts": [{ "matches": [

How to transfer data between the content scripts of two different tabs?

自闭症网瘾萝莉.ら 提交于 2019-12-18 12:47:17
问题 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' 回答1: First,

How can I make a Chrome extension automatically click a button when a page loads?

此生再无相见时 提交于 2019-12-18 12:02:34
问题 I'm trying to create a Google Chrome extension that presses a button on page load. I've been able to trigger the button using VBscript for Internet Explorer by using this code: IE.Navigate("javascript:changeIframe();") But, now I need to do it in Google Chrome via an extension. However, the button does not have an id: <input type="button" value="Start!" onclick="javascript:changeIframe();"> and here's what I've tried so far and nothing seems to work: window.onload="javascript:changeIframe()";

Options-enabled content-script Chrome extension without background page?

喜夏-厌秋 提交于 2019-12-18 05:14:17
问题 I'm making a content script extension for Google Chrome, it adds functionality to a website's page. I want to add a couple of options, not big deal really, I'd just need two strings (none of which are sensitive user data). From this answer, I assume I need a background page, which I'd rather not add to my extension - I don't want it to gain unnecessary weight. Do I really need a background page, or I could have an options page without it (and which storage could I use)? 回答1: UPDATE As of

How to load a content script on all Google (international) pages?

北战南征 提交于 2019-12-18 04:47:07
问题 For a Google-Chrome extension, I would like to load a content script on all Google pages. What is the best way to do this? I tried this, in the manifest.json , but it does not work: "matches": ["http://www.google.*/*", "https://www.google.*/*"], This "works" but it is a bit long to write and I do not think it is the best practice: "matches": ["http://www.google.com/*", "https://www.google.com/*", "http://www.google.fr/*", "https://www.google.fr/*", "http://www.google.de/*", "https://www

Chrome extension regarding injected script + localstorage

*爱你&永不变心* 提交于 2019-12-17 21:16:57
问题 I am puzzling my way through my first 'putting it all together' Chrome extension, I'll describe what I am trying to do and then how I have been going about it with some script excerpts: I have an options.html page and an options.js script that lets the user set a url in a textfield -- this gets stored using localStorage. function load_options() { var repl_adurl = localStorage["repl_adurl"]; default_img.src = repl_adurl; tf_default_ad.value = repl_adurl; } function save_options() { var tf_ad =

how to make on/off buttons/icons for a chrome extension?

孤人 提交于 2019-12-17 20:19:30
问题 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 32x32 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): ...

Chrome content scripts aren't working: DOMContentLoaded listener does not execute

余生长醉 提交于 2019-12-17 20:05:11
问题 I am trying to code extension that corrects misspellings on 1 forum. I am trying to access <p> tag, with content script, but it doesn't change anything (using the code below): document.addEventListener("DOMContentLoaded", function() { document.getElementsByTagName("P")[4].innerHTML = "correct_word"; }); It doesn't change anything when added as an extension, apparently if I wget the page, and put the script there, all works. Any thoughts? My manifest.json file: { "manifest_version": 2, "name":

Difference between background script and content script in chrome extension

ε祈祈猫儿з 提交于 2019-12-17 18:16:56
问题 As the questions says, I just want to know the difference between background script and content script in chrome extension. When I logged the chrome object in both the scripts, I found the different objects. Use case I want to inject my javascript into the page when the icon is clicked So in manifest.json I added a content script but I am unable to listen to icon click event inside content script. chrome.browserAction is not defined in chrome object in content script. Question How can I