google-chrome-extension

Checking if user has a certain extension installed

巧了我就是萌 提交于 2019-12-17 18:25:13
问题 I just found out that the Screen Capture by Google extension makes my website's window.onresize event not fire. I want to perform a javascript check to see if the user has ScreenCapture installed and if so, warn the user of the problem. A year ago I think I heard of some javascript code that could do this, maybe using some google API, but I don't remember. Any insight on this? I haven't developed any extensions so I don't really know how they work. [EDIT] So I have been asked to show some

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

Google Chrome Extension: Cannot launch Print dialog

我怕爱的太早我们不能终老 提交于 2019-12-17 17:23:34
问题 I'd like to launch the print dialog on button click in my google chrome extension. The code seems to be working when the extension's html file is opened as a standalone file, but not when it's loaded as an extension. HTML: <input id="print_page" type="button" value="Print" onclick="print_p()" /> JavaScript: function print_p(){ window.print();} Any idea as to what's wrong? 回答1: Aside from the inline JavaScript problem that I mentioned as a duplicate, it seems that invoking the print dialog

Run javascript with click on popup.html icon in Chrome extension

狂风中的少年 提交于 2019-12-17 17:18:17
问题 What I want is simple. The user clicks on the icon of the extension and a JS code is executed showing a prompt box asking for two values. But I cannot figure out how to link the JS with the popup.html correctly. So far with the click on the icon only the popup opens without running the JS code. popup.html <!DOCTYPE html> <html> <head> <script type="text/javascript" src="prompt.js"></script> </head> <body onload="promptBox()"> </body> </html> prompt.js function promptBox() { prompt('Choose

Gmail Chrome Extension “chrome.extension” undefined

时间秒杀一切 提交于 2019-12-17 17:16:15
问题 I have a content script running inside the Gmail UI and I am injecting some new HTML at different points. This is all working, but to keep the code clean I wanted to insert pre-defined HTML markup into certain parts of the page in a single function call. This all seems feasible using chrome.extension.getURL(), but when I was testing this, it looks like chrome.extension is undefined! I was unable to find anywhere in the documentation that says this shouldn't be defined and several places where

Extract the whole text contained in webpage using Chrome extension

↘锁芯ラ 提交于 2019-12-17 16:54:07
问题 I'm developing a Chrome extension for text parsing of Google search results. I want the user to insert a certain text in the omnibox, and then be direct to a Google search page. function navigate(url) { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.update(tabs[0].id, {url: url}); }); } chrome.omnibox.onInputEntered.addListener(function(text) { navigate("https://www.google.com.br/search?hl=pt-BR&lr=lang_pt&q=" + text + "%20%2B%20cnpj"); }); alert('Here is

Extract the whole text contained in webpage using Chrome extension

梦想的初衷 提交于 2019-12-17 16:54:01
问题 I'm developing a Chrome extension for text parsing of Google search results. I want the user to insert a certain text in the omnibox, and then be direct to a Google search page. function navigate(url) { chrome.tabs.query({active: true, currentWindow: true}, function(tabs) { chrome.tabs.update(tabs[0].id, {url: url}); }); } chrome.omnibox.onInputEntered.addListener(function(text) { navigate("https://www.google.com.br/search?hl=pt-BR&lr=lang_pt&q=" + text + "%20%2B%20cnpj"); }); alert('Here is

Google Chrome Extension - Programmatically Open Popup

谁都会走 提交于 2019-12-17 16:49:09
问题 When you make a Google Chrome Extension you can choose to have a "Default_Popup", is there any way to programmatically open the popup? 回答1: There is no direct way to open the popup programmatically. However, if you're looking to open it based on a keyboard shortcut, you can use the commands API with the _execute_browser_action command (the API is currently available on the beta channel only). 回答2: There is an API, chrome.browserAction.openPopup(function callback), that will hopefully be

How are Chrome Extension's weekly users counted? Is it the number of users who have it installed? Or the one's clicking on popup?

末鹿安然 提交于 2019-12-17 16:42:09
问题 Just wondering what is meant by "Weekly users" in Chrome Webstore? Is it the number of users who have clicked on the popup? Or does it also count if the users are just browsing while the Content Script is at work? What happens if an extension uses both content script and popup? 回答1: According to Joe Marini (lead Developer relations for Chrome apps/extensions/CWS): The number [of weekly users] you see in the Chrome Web Store is the amount of users whose Chrome browser has checked for an update

Changing navigator.userAgent using Chrome Extension

雨燕双飞 提交于 2019-12-17 16:05:50
问题 I am trying to overload the navigator.userAgent using a simple chrome extension. As the content scripts operate in isolated env, I tried to create a script element and write the logic into this one. This happens from background page of the extension chrome.tabs.query({ active:!0 }, function(tabs) { var x = "window.navigator.__defineGetter__('userAgent', function() {" + "return 'Mozilla/5.0 (Linux; Android 4.2.1; en-us; Nexus 5 Build/JOP40D)" + " AppleWebKit/535.19 (KHTML, like Gecko) Chrome