google-chrome-extension

JavaScript + Chrome Tabs Api - can't get tab's URL

孤街浪徒 提交于 2019-12-12 19:12:02
问题 I have the following piece of code and the problem is that the callback from chrome.tabs.getSelected is evaluated after the request which is send with empty url. How can I solve this? function send() { var url = ''; chrome.tabs.getSelected(null, function(tab) { url = tab.url; }); var client = new XMLHttpRequest(); client.onreadystatechange = function() { if(this.readyState == 4) { alert(this.status); } } client.open("POST", "http://myurl"); client.setRequestHeader("Content-Type", "text/plain

How to make the page script recognize a manually changed value of INPUT element?

匆匆过客 提交于 2019-12-12 18:58:46
问题 I'm working on a Chrome extension and am currently trying to get my content script to automatically do a search using the form on the site. I'm doing this by changing the value of the input and then using the jQuery change() method, since the site doesn't start searching otherwise. var search = $("#videoSearchInput"); search.val("test"); search.change(); I've figured out that the change() method solves my problem by executing it through the Chrome console, but it doesn't work when I try to

Chrome extension used to refresh pages

江枫思渺然 提交于 2019-12-12 18:33:00
问题 I was trying to develop a Chrome extension that can display me the last 3 news from a soccer news site (obviously the page is not open in any tab), by refreshing every 5 minutes. My ideea was to load the page inside an iframe and, once the page is loaded, access the page DOM and extract only the text nodes with the news. I've tried in many ways using ready and load functions, I tried to follow this solutions here but i always get warnings. My question is: is there a way I can do that without

How to enable chrome extension without user intervention (programmatically)

泪湿孤枕 提交于 2019-12-12 18:29:01
问题 I made a chrome extension and want its installation to be done as a part of software installation setup using windows registry. It installs the extension for chrome, but in disabled state. Extension is listed in the list of installed extension in chrome://extensions. How can I enable the extension using code(without end-user intervention). I don't want my user to enable it manually. 回答1: You can't directly enable chrome extension because of chrome security police(After Chrome 25). Extensions

Working between Popup and Background Chrome Extension

谁都会走 提交于 2019-12-12 18:24:02
问题 I am trying to set a variable in popup window, labeled i and then send it to the background page. I believe that I can put the variable in as the "request", but I might be wrong about that. When I try to run the extension I get: Uncaught TypeError: Cannot call method 'sendRequest' of undefined What am I missing? Here is my popup.html file: var i = 0; function start(){ alert("working"); chrome.tabs.sendRequest(i); } function add(){ i++; document.getElementById('box').value=i; } function sub(){

HEAD XMLHttpRequest on Chromium

二次信任 提交于 2019-12-12 18:17:36
问题 I'm trying to get the HEAD response with an XMLHttpRequest in Chromium to retrive the location URL of a compressed url, but it fails: var ajax = new XMLHttpRequest(); ajax.onreadystatechange = function() { if (ajax.readyState == 4) alert(ajax.getResponseHeader("Location")) }; ajax.open('HEAD', "http://bit.ly/4Agih5", false); ajax.send(); // Refused to get unsafe header "Location" // Error: NETWORK_ERR: XMLHttpRequest Exception 101 回答1: As Mohamed indicated, you will have to create a proxy

How to get the unique user ID in a chrome extension using OAuth?

断了今生、忘了曾经 提交于 2019-12-12 18:13:03
问题 I am using the identity permission in my manifest file and in my JavaScript code I use chrome.identity.getAuthToken({ 'interactive': true }, function( token ) to get the use identification token. How do I get the unique user ID or e-mail address? Preferrably without adding new permissions. 回答1: You can use chrome.identity.getProfileUserInfo() to get both the email address and a unique id. You will need to add the identity.email permission (in addition to identity ). It does not require an

chrome.runtime.reload blocking the extension

久未见 提交于 2019-12-12 18:04:57
问题 So, I'm developing a plugin for webpack for hot-reloading the chrome extensions. The biggest problem is, if I call a certain number of times the "chrome.runtime.reload()" this will make Chrome block the extension: This extension reloaded itself too frequently. On a old discussion they said that if you call the reload more than 5 times in a 10 seconds time frame, your extension will be blocked. The thing is, I've throttled the reloading a lot (like max 1 call each 5 seconds) and this still

Keyboard shortcuts in Chrome extensions

一笑奈何 提交于 2019-12-12 17:24:15
问题 I'm trying to hook up a keyboard shortcut for my chrome extension. I'm using a jQuery plugin for this: http://oscargodson.com/labs/jkey/. Here's the code I'm using to test it out: $(document).ready(function() { function say_hello() { alert("hello!"); } $(document).jkey('/', say_hello); }); I have this in my background page right now, but it doesn't work. Is this type of code something that should go in the background page, or something that's more appropriate for a content script? Or should I

Can't set focus to input in chrome extension

假装没事ソ 提交于 2019-12-12 17:17:25
问题 For some reason I can't set focus on a texbox I have in my popup.html. Here's what I've tried so far: popup.html: <input type="text" id="textbox" name="aName" value="" placeholder="blah" /> popup.js: //Attempt 1 $(function() { $('#textbox').focus(); }); //Attempt 2 setTimeout(function() { $('#textbox').focus(); }, 1000); I also tried without javascript, using just the autofocus property: <input type="text" id="textbox" name="aName" value="" placeholder="blah" autofocus /> But none of this