google-chrome-extension

chrome extension - best method of reducing load time while using content scripts

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 16:53:47
问题 I'm building a chrome extension that is supposed to look through an array of over 12,000 values and compare it to the webpages p tags, and if a value from the array is inside the p tag it should highlight the text and when hovered it should display some information. So, easy enough I suppose using content scripts but using "run_at": "document_end" made the webpage load 3 times slower, almost 10 seconds more to load with my extension. Obviously not ideal. This is my content script code by the

Can a Chrome extension toggle Switches normally set as command line flags?

僤鯓⒐⒋嵵緔 提交于 2019-12-23 15:56:35
问题 I'm wondering if I would be able to write a chrome extension that would be able to toggle Switches in the browser, similar to how using the command line flag: "--disable-web-security" works. In an ideal world, I would only set this flag for a single tab, but the ability to toggle the security flag on and off within the browser would be a good start. Any ideas on if/how this can be accomplished? 回答1: Unfortunately, there is no API for this. 来源: https://stackoverflow.com/questions/32210069/can

Get selected text in an input box

送分小仙女□ 提交于 2019-12-23 15:00:27
问题 Is it possible to get the selected text in an input box of a website, using either jQuery or vanilla JavaScript? I have tried with var selectedText = window.getSelection().toString(); , but this code only gets the text in a paragraph and not in an input box . EDIT: Maybe I was unclear, I want to get the text from a website that I didn't create. I'm building a Chrome extension and I need to get the text from an input box of a website. 回答1: Came with solution Find below function disp() { var

chrome extension: run script after page has finished loading javascript

…衆ロ難τιáo~ 提交于 2019-12-23 14:22:35
问题 this is not firing at all when the page finishes loading. Basically when I click the browser action button, it will trigger it on, and on page load, it will run a script. In my background.js var toggle = false; chrome.browserAction.onClicked.addListener(function(tab) { toggle = !toggle; if(toggle){ chrome.browserAction.setIcon({path: "icons/logo.png", tabId:tab.id}); // chrome.tabs.executeScript(tab.id, {file:"SCRIPT.user.js"}); chrome.tabs.executeScript(tab.id, {code:"alert('aaxxxbbaa')"});

chrome extension: run script after page has finished loading javascript

拟墨画扇 提交于 2019-12-23 14:22:26
问题 this is not firing at all when the page finishes loading. Basically when I click the browser action button, it will trigger it on, and on page load, it will run a script. In my background.js var toggle = false; chrome.browserAction.onClicked.addListener(function(tab) { toggle = !toggle; if(toggle){ chrome.browserAction.setIcon({path: "icons/logo.png", tabId:tab.id}); // chrome.tabs.executeScript(tab.id, {file:"SCRIPT.user.js"}); chrome.tabs.executeScript(tab.id, {code:"alert('aaxxxbbaa')"});

Access Chrome settings in Chrome Extension

社会主义新天地 提交于 2019-12-23 12:47:10
问题 I'm looking to develop a chrome extension that can access the Content Settings in [wrench] -> Options -> Under the Hood. Is that possible? I was looking on the API page and had no luck. Any ideas? 回答1: If it's the language settings you're after, you can use the i18n support to get the browser language by defining different strings in each locale file, then reading it in your main script. It doesn't look like you can obtain the font settings, not through the Chrome APIs at least. 来源: https:/

Ability to launch chrome with extensions loaded with watir-webdriver

五迷三道 提交于 2019-12-23 12:45:09
问题 I'm attempting to launch chrome using watir-webdriver but with a specific extension loaded. I haven't been able to figure out how to do this in ruby. When I run the following code @browser = Watir::Browser.new(:chrome, :switches => %w[--load-extension="file path of the extension"]) I will get this message: Now what I noticed was odd was the dual path. I'm not sure where the first half of the path is coming from ("...Google\Chrome\Application\21..."). The 2nd half of it is what I specified in

Creating a dynamic Chrome theme

喜欢而已 提交于 2019-12-23 12:28:24
问题 I'm trying to build a theme extension for Google Chrome that will regularly update the background image using a remote image source (i.e. images are stored on a web server, not locally). The problem is that themes are not allowed to contain scripting elements. Any suggestions how to work around this restriction? 回答1: If by background image you mean the background of the New Tab page, you can replace it with an html page (using an extension, not a theme, that is): http://code.google.com/chrome

chrome.tabCapture.capture returned stream is undefined

China☆狼群 提交于 2019-12-23 12:22:51
问题 I've got some js code in a chrome background extension of the following : function handleCapture(stream) { console.log('content captured'); console.log("backround.js stream: ", stream); alert(stream); // localStream = stream; // used by RTCPeerConnection addStream(); // initialize(); // start signalling and peer connection process } function captureCurrentTab() { console.log('reqeusted current tab'); chrome.tabs.getSelected(null, function(tab) { console.log('got current tab'); var

Can a Chrome extension monitor XHR events (or other events) from the page it's running against?

跟風遠走 提交于 2019-12-23 11:55:21
问题 I'm building a Chrome extension that manipulates the content of the page, but the content I'm interested in only shows up when the user has clicked a button and the data has then been loaded from an Ajax call. At the moment the extension monitors the page with a SetTimeout but it's clumsy. Can an extension know when an Ajax call has been initiated, and when it ended? or can the extension somehow receive events from the page? 回答1: I don't know an easy way to monitor XHR requests, but you can