google-chrome-extension

Why is chrome.cookies undefined in a content script?

早过忘川 提交于 2019-12-18 16:11:06
问题 Whenever I try to read from a cookie using the chrome.cookies.get() function I get this error: TypeError: Cannot read property 'get' of undefined. I am calling the function in my content.js file, and it will only run on twitter.com(that part works). Here is my manifest file: { "manifest_version": 2, "name": "Twitter-MultiSignin", "description": "twiter sign in", "version": "1.0", "permissions": [ "cookies", "alarms" , "http://*/*", "https://*/*", "storage"], "content_scripts": [{ "matches": [

how to enable screen/desktop capture in chrome?

浪尽此生 提交于 2019-12-18 15:54:29
问题 I am able to achive it in firefox by folowing below steps: make my server https append my domain to the user preference media.getusermedia.screensharing.allowed_domains in about:config to whitelist it for screen sharing. use constraint like {video: {mediaSource: "screen"}} , but in chrome, I am getting totally lost. most places keep telling: You'll need to first enable the flag called Enable screen capture support in getUserMedia() in chrome://flags. ( but I am unable to find this flag

Chrome extension setTimeout not working properly

别说谁变了你拦得住时间么 提交于 2019-12-18 15:48:24
问题 My first post here =]. I'm building a chrome extension and I'm using a setTimeout recursively. I noticed that if I set it to up to 13secs, it works, but if I set it to 14secs+ it won't work. This is an example which is on my background.js function start() { var timeout = setTimeout( function() { start(); }, 1000*15); alert('test'); } chrome.webNavigation.onCompleted.addListener(function(o) { start(); }, { url: [ {urlContains: 'http://www.example.com/in.php'}, {urlContains: 'http://www.example

Synchronous message passing in chrome extensions?

99封情书 提交于 2019-12-18 15:35:42
问题 I'm trying to block a script file from loading on user defined websites. To block a script file I'm using beforeload event and event.preventDefault(); in content script which works fine as long as I already know website list. My problem is I don't know website list in advance, so to get the website list I'm sending a request to background page but response is asynchronous and unusable. Is there any synchronous message passing in Chrome Extensions that I possibly missed in Google's docs? // my

Tab key not working in popup in chrome extension

China☆狼群 提交于 2019-12-18 15:34:33
问题 I have created a chrome extension that has a popup with the following HTML markup in it: <html> <head> <style> body { font-family: 'Open Sans',arial,sans-serif; background-color: #E5E5E5; font-size: 13px; text-shadow: 0px 1px rgba(255, 255, 255, 0.5); } </style> </head> <script type="text/javascript">function sendRequest(s,r){ chrome.tabs.getSelected(null, function(tab) { chrome.tabs.sendRequest(tab.id, {search:s , replace:r}, function(response) { console.log(response.farewell); }); }); }; <

How do I give webkitGetUserMedia permission in a Chrome Extension popup window?

泄露秘密 提交于 2019-12-18 14:56:33
问题 I've successfully used webkitGetUserMedia to capture video from my webcam on a normal webpage, but when I try to do this in the popup.html of my Chrome Extension nothing happens. I don't get any permission errors, it just never even seems to ask (the inforbar never slides down in the popup window). Is there any way around this? It doesn't look like I can give permissions in the manifest json. 回答1: It's a cheap hack, but if you create an options page for your extension and include a call to

accessing the current html page from chrome extension

亡梦爱人 提交于 2019-12-18 14:52:12
问题 I'm new to chrome extensions. I would like to create a simple chrome extension that popup an alert with the title of the current html page. when I'm performing: alert(document.title) , I'm not getting it because the document object doesn't belong to the page but to the extension script (is it correct?) how do i get the right document object? 回答1: You can use the tabs module: chrome.tabs.getCurrent(function(tab) { alert(tab.title); }); 回答2: Content scripts are the easiest way to go: Expand

accessing the current html page from chrome extension

孤者浪人 提交于 2019-12-18 14:52:01
问题 I'm new to chrome extensions. I would like to create a simple chrome extension that popup an alert with the title of the current html page. when I'm performing: alert(document.title) , I'm not getting it because the document object doesn't belong to the page but to the extension script (is it correct?) how do i get the right document object? 回答1: You can use the tabs module: chrome.tabs.getCurrent(function(tab) { alert(tab.title); }); 回答2: Content scripts are the easiest way to go: Expand

Can an app or extension open files on system with permission “<all_urls>”?

╄→尐↘猪︶ㄣ 提交于 2019-12-18 13:37:58
问题 I thought Chrome apps were sandboxed, but I see that you can allow permissions for file:// urls, and there's a special matching pattern: <all_urls> Matches any URL that uses a permitted scheme. (See the beginning of this section for the list of permitted schemes.) Are the file urls restricted to within the sandbox or can it really go anywhere? 回答1: Yes, you can access the entire filesystem (subject to the permissions of the user account running Chrome). However , the user must explicitly

Chrome extension - Message Passing

大憨熊 提交于 2019-12-18 13:34:49
问题 I'm trying to get the info that is set on the Options Page to alter the behavior of my extension. Basically, if a checkbox on OptionsPage is set to true, the extension runs, otherwise it doesn't. I'm returning true on the background.html for testing purposes, but still, it doesn't work. Would you guys help me out? Thanks! Code being injected to the page: if(chrome.extension.sendRequest() == 'true') alert("checkbox set to true"); else alert("it is disabled"); background.html <script> chrome