google-chrome-extension

Google Chrome Extension get page information

浪尽此生 提交于 2019-12-30 04:24:13
问题 I'm making a google chrome extension, and I need to get the current page URL and title. How can I achieve this? 回答1: chrome.tabs.getSelected(null, function(tab) { //<-- "tab" has all the information console.log(tab.url); //returns the url console.log(tab.title); //returns the title }); For more please read chrome.tabs. About the tab object, read here. Note: chrome.tabs.getSelected has been deprecated since Chrome 16. As the documentation has suggested, chrome.tabs.query() should be used along

Detecting if code is being run as a Chrome Extension

笑着哭i 提交于 2019-12-30 04:05:48
问题 I am working with some code that needs to be run as a page, and if it's being run as a Chrome Extension, I want to be able to do additional things. What I'm using is: <script> if (chrome && chrome.extension) { // extension stuff } </script> This seems like a good capability detection. Using user agent string causes me trouble because it's the same no matter the context (web page vs. extension). Question: are there other more reliable techniques for detecting if a piece of code is running

Greasemonkey, Chrome and unsafeWindow.foo()

末鹿安然 提交于 2019-12-30 03:28:06
问题 I have the following anchor tag, which contains dynamically-generated arguments arg1,...,arg5 to the JavaScript function foo() , which runs on the web site-side. There are several of these anchor tags throughout the page in question, with unique id values and argN values: <a href="#" id="foo1234567890" onclick="javascript:foo(arg1,arg2,arg3,arg4,arg5);return false;" target="_self" title="foobarbaz"> blah </a> I would like to programmatically fire the foo() function by looping through all hits

Paypal Button For Google Chrome Extension

有些话、适合烂在心里 提交于 2019-12-30 03:24:07
问题 I'm attempting to add a donate button (because I like money) to my google chrome extension. I'm having trouble with it because the Chrome extension tries to open the paypal created donation button in the popup.html window. When I click the button, my extension just restarts and there is no donation window. I have tried using chrome.tab.create() to try to make it open to a tab but it doesn't seem to have any effect. The code to the donation button is as follows: <form action="chrome.tabs

Can not make GWT application work as Chrome packaged app, probably due to CSP

妖精的绣舞 提交于 2019-12-30 03:18:27
问题 Keep getting CSP errors: "Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self'" The problem is probably due to HTML files generated by GWT which contain inline JS. UPD : Changing to manifest version 1 helped, but this is a temporary workaroud, as Chrome 21 complains that it will no longer be supported. UPD2: <add-linker name="xsiframe" /> does not help either 回答1: GWT 2.5.1 has finally fixed this problem. The release notes

How do I use chrome.tabs.onUpdated.addListener?

為{幸葍}努か 提交于 2019-12-30 03:15:26
问题 I am creating an extension for Chrome. I want to show an alert() with the page URL whenever the user moves from one tab to another, or when the user enters a new URL in a tab. This is not working: chrome.tabs.onUpdated.addListener(function(integer tabId, object changeInfo, Tab tab) { alert(changeInfo.url); }); chrome.tabs.onActivated.addListener(function(object activeInfo) { // also please post how to fetch tab url using activeInfo.tabid }); 回答1: Remove integer , object and Tab in the

Link to chrome://chrome/extensions from extension options page

我的梦境 提交于 2019-12-30 03:09:27
问题 I'm using the chrome bootstrap styles (see http://roykolak.github.com/chrome-bootstrap/) to build my options page. Now I'd like to have a link back to chrome://chrome/extensions in the left-sidebar menu, but clicking on it returns an error in the console: Not allowed to load local resource: chrome://chrome/extensions 回答1: You can open this with chrome.tabs.update , you don't need the tabs permission for this. options.html <script src="options.js"></script> <a href="#" id="test">test</a>

How get Facebook token using Oauth2 with chrome.identity

柔情痞子 提交于 2019-12-30 02:32:44
问题 I'm using chrome.identity in a packaged app to get a user token using Facebook. I call chrome.identity.launchWebAuthFlow, and I need to take the access token, send it to the server, and then access token is used to verify the user. Works great with Google+. But for some reason, it doesn't work for Facebook. For some reason, Facebook's OAuth appears to be special. I've added the extensionid.chromiumapp.org to the list of redirect URLs in the API. Added "https://extensionid.chromiumapp.org/*",

How to programmatically calculate Chrome extension ID?

我是研究僧i 提交于 2019-12-30 02:16:10
问题 I'm building an automated process to produce extensions. Is there a code example of calculating the extension-ID directly and entirely bypassing interaction with the browser? (I'm answering my own question, below.) 回答1: I was only able to find a related article with a Ruby fragment, and it's only available in the IA: http://web.archive.org/web/20120606044635/http://supercollider.dk/2010/01/calculating-chrome-extension-id-from-your-private-key-233 Important to know: This depends on a DER

Google Chrome Extensions: How to detect Copy action (Ctrl-C and Edit-Copy)?

半腔热情 提交于 2019-12-30 01:25:27
问题 How might I detect that a user has selected and copied some content in the currently active tab in a Google Chrome Extension? It appears that there are no suitable Events that deal with the Clipboard in chrome.tabs or chrome.windows. Is there a way to detect such actions through Content Scripts? 回答1: I found the following solution: Set up a manifest file to define a content script that is added to every page, and a separate background page. In the Content Script .js file, add an event