google-chrome-extension

content security policy issue with chrome extension

99封情书 提交于 2020-01-02 07:46:05
问题 Trying to load different contents(can be pdf, swf etc.) in an 'iframe' through javascript in an chrome extension application. The content is loaded using the data URL scheme as : // this javascript is registered in the html file and the LoadFunction is registered inside the DOMContentLoaded event on the click of a button. void LoadFunction() { window.parent.document.getElementById("page_data").src = 'data:application/pdf;base64,' + 'base64 encoded data'; (base64 data is received from a c++

What is the best to identify machine/user in Google Chrome Extention?

一个人想着一个人 提交于 2020-01-02 07:31:32
问题 I have a web app and complementing chrome extension for it, which sends data in background to the web app. Now, I want to send this data to the corresponding user account in the web app. What method should I use? How should I handle the authentication? I was thinking if there was some way to identify machine ID or something which I can register while user is signing up, but I cannot see any method to get machine ID. Please suggest a best way to implement this. Thanks! 回答1: Here is what I am

Google Chrome Extension: captureVisibleTab problem

女生的网名这么多〃 提交于 2020-01-02 06:30:30
问题 I'm trying to capture the current visible tab but I'm receiving undefined. The following code is executing when the extension's icon is pressed. When the alert is called I see undefined instead of an URL. chrome.browserAction.onClicked.addListener(function(tab) { chrome.windows.getCurrent(function (win) { chrome.tabs.captureVisibleTab(win.id,{"format":"png"}, function(imgUrl) { alert(imgUrl); }); }); }); What should I do to get the URL of the captured image? Can someone please help me out

Match all URLs except certain URLs in Chrome Extension

本秂侑毒 提交于 2020-01-02 06:12:10
问题 I'm trying to have it so that my content script runs on every site except for 3. I know there's probably a way to do it with regex but I'd prefer not to. Does the chrome extension manifest allow for exceptions? If regex is the only solution and anyone knows the pattern to exclude these 3 URLs that would be great too. https://www.linkedin.com/ https://mail.google.com/ https://twitter.com/ 回答1: https://developer.chrome.com/extensions/content_scripts lists an option exclude_matches : "content

Chrome Extension Replace word in current textarea

穿精又带淫゛_ 提交于 2020-01-02 05:40:27
问题 I'm trying to make a chrome extension that replaces the last word typed in the current <textarea> when the user makes a certain keydown event fire. So I've tried this but it doesn't really work. Here are the files of my extension: My extension's manifest.json : { "name": "Test", "description": "test", "version": "0.0.1", "permissions": [ "activeTab" ], "background": { "scripts": ["background.js"], "persistent": false }, "browser_action": { "default_title": "replace test" }, "manifest_version"

With a chrome extension how can add html to just below the body tag of a page?

删除回忆录丶 提交于 2020-01-02 05:30:08
问题 I want to have a chrome extension that adds a little bar to the top of certain sites. A bar similar to the one you have at the top of this site if you are logged in. From what I have read I need to do this with a content script and I have tried various things. At present I have a file called content.js which has the following var iframe = document.createElement("iframe"); iframe.src = chrome.extension.getURL("iframe.html"); document.body.appendChild(iframe); The iframe.html file is just this

Chrome Extension Desktop Notification Works On Sleep

你离开我真会死。 提交于 2020-01-02 05:13:08
问题 I made a Desktop Notification it shows a notification every 1 minute. After 10 second, closes itself. I gone for a lunch , then computer goes to sleep. When i was back i wake my computer then lots of notification starts. How can i handle that problem? I want if computer sleeps it shouldnt show notification. How can i control it? Background.js function show() { var notification = webkitNotifications.createHTMLNotification( 'notification.html' ); notification.show(); } // Conditionally

Ajax request succeeds but result is empty

人走茶凉 提交于 2020-01-02 04:01:06
问题 I am building a Google Chrome browser extension that uses $.ajax requests to send data from webpages to my server (currently hosted using localhost). The content_script.js file that is being executed in the context of the webpages (more on content scripts) that the extension has access to runs this code: //note: encode64String is assigned earlier in the script... $.ajax({ type: "POST", url: "http://localhost:8888/quartzsite/uploadendpoint.php", type: "jsonp", data: {img: encode64String},

Chrome extensions: make chrome.tabs.query() synchronous

Deadly 提交于 2020-01-02 03:40:11
问题 I am currently using this code: url = "unknown"; chrome.tabs.query({'active': true, 'lastFocusedWindow': true}, function(tabs) { console.log(tabs); //test, prints one-element array as expected url = tabs[0].url; }); $("#url_div").html(url); to get current URL, but chrome.tabs.query() is asynchronous , how can I make it synchronous? (i.e. add asynch: false somewhere) I know I could set the URL inside the query, or call another function from there, but best would be (example is simplifed) if it

chrome.runtime.getURL vs. chrome.extension.getURL

陌路散爱 提交于 2020-01-02 02:37:09
问题 What are the differences between chrome.runtime.getURL and chrome.extension.getURL? The documentation implies that chrome.runtime.getURL works in both apps and extensions, and this 2012 announcement indicates that some APIs (though not getURL ) have moved from chrome.extension to chrome.runtime . What's the point of chrome.extension.getURL then, and why isn't it deprecated in favor of chrome.runtime.getURL ? 回答1: The chrome.extension.getURL is now deprecated , you should use chrome.runtime