google-chrome-extension

Google Chrome Extensions - Open New Tab when clicking a toolbar icon

二次信任 提交于 2019-12-17 07:11:28
问题 How can I create an extension for Chrome that adds an icon to the toolbar, and when you click it, it opens a new tab with some local web page (for example: f.html)? I saw this question, but it doesn't really explains what should I add in the manifest file... 回答1: This is not true for newer chrome apps. Newer chrome apps having manifest_version: 2 requires the tabs be opened as: chrome.browserAction.onClicked.addListener(function(activeTab) { var newURL = "http://www.youtube.com/watch?v

How do you integrate Universal Analytics in to Chrome Extensions?

走远了吗. 提交于 2019-12-17 07:09:04
问题 The chrome extension guide has a tutorial for the old analytics install: https://developer.chrome.com/extensions/tut_analytics.html The instructions just say to link to the https version and update the manifest to allow loading scripts from that URL. So those should still apply to the new version. And in fact I can see the script loading from the server. Once the script loads analytics does not properly initialize it self and never processes it's internal queue (ga.f) to send those events to

String compression in JavaScript

送分小仙女□ 提交于 2019-12-17 06:30:16
问题 I'm looking for a JavaScript function that given a string returns a compressed (shorter) string. I'm developing a Chrome web application that saves long strings (HTML) to a local database. For testing purposes I tried to zip the file storing the database, and it shrank by a factor of five, so I figured it would help keep the database smaller if I compressed the things it stores. I've found an implementation of LZSS in JavaScript here: http://code.google.com/p/u-lzss/ ("U-LZSS"). It seemed to

String compression in JavaScript

筅森魡賤 提交于 2019-12-17 06:30:07
问题 I'm looking for a JavaScript function that given a string returns a compressed (shorter) string. I'm developing a Chrome web application that saves long strings (HTML) to a local database. For testing purposes I tried to zip the file storing the database, and it shrank by a factor of five, so I figured it would help keep the database smaller if I compressed the things it stores. I've found an implementation of LZSS in JavaScript here: http://code.google.com/p/u-lzss/ ("U-LZSS"). It seemed to

about chrome.tabs.executeScript( id,details, callback)

可紊 提交于 2019-12-17 06:08:21
问题 This function has a callback like function(array of any result) {...}; But I don't know what is the result means. For example, chrome.tabs..executeScript(null, {code:"var x = 10"}, function(){}); how to return the x to the callback? 回答1: The result of a script is the last expression being evaluated. So in your example you could use: chrome.tabs.executeScript( null, {code:"var x = 10; x"}, function(results){ console.log(results); } ); This will log [10] to the extension's console. results is

How to communicate between popup.js and background.js in chrome extension?

我的梦境 提交于 2019-12-17 05:38:00
问题 The message from popup.js is being posted twice to background.js, but I get absolutely nothing from background.js. background.js function login(username,password){ console.log(username); var xhr = new XMLHttpRequest(); xhr.open("POST", "http://localhost:3000/login/", true); xhr.setRequestHeader('Content-type','application/json; charset=utf-8'); data = {"username":username,"password":password}; console.log(JSON.stringify(data)); xhr.send(JSON.stringify(data)); xhr.onreadystatechange = function

How to communicate between popup.js and background.js in chrome extension?

狂风中的少年 提交于 2019-12-17 05:37:04
问题 The message from popup.js is being posted twice to background.js, but I get absolutely nothing from background.js. background.js function login(username,password){ console.log(username); var xhr = new XMLHttpRequest(); xhr.open("POST", "http://localhost:3000/login/", true); xhr.setRequestHeader('Content-type','application/json; charset=utf-8'); data = {"username":username,"password":password}; console.log(JSON.stringify(data)); xhr.send(JSON.stringify(data)); xhr.onreadystatechange = function

Where does Chrome store extensions?

戏子无情 提交于 2019-12-17 05:32:31
问题 I looked in: C:\Documents and Settings\username\Local Settings\Application Data\Google\Chrome\User Data\Default\Extensions for unpacked extensions, but that folder is empty for me. For newer versions, where does Chrome store the files? 回答1: Storage Location for Unpacked Extensions Extension engine does not explicitly change their location or add a reference to its local paths, they are left in the place where there are selected from in all Operating Systems . Ex: If i load a unpacked

Content-Security-Policy error in google chrome extension making

别来无恙 提交于 2019-12-17 05:12:12
问题 I am making a chrome extension that will open all links on a page in new tabs. Here are my code files: manifest.json { "name": "A browser action which changes its icon when clicked.", "version": "1.1", "permissions": [ "tabs", "<all_urls>" ], "browser_action": { "default_title": "links", // optional; shown in tooltip "default_popup": "popup.html" // optional }, "content_scripts": [ { "matches": [ "<all_urls>" ], "js": ["background.js"] } ], "manifest_version": 2 } popup.html <!doctype html>

Optionally inject Content Script

此生再无相见时 提交于 2019-12-17 05:04:25
问题 Content Script can be injected programatically or permanently by declaring in Extension manifest file. Programatic injection require host permission, which is generally grant by browser or page action. In my use case, I want to inject gmail, outlook.com and yahoo mail web site without user action. I can do by declaring all of them manifest, but by doing so require all data access to those account. Some use may want to grant only outlook.com, but not gmail. Programatic injection does not work