google-chrome-extension

Chrome extension > contextMenus Api > can not add onclick handler

自作多情 提交于 2019-12-18 07:19:07
问题 I am trying to create a chrome extension. Currently I am about to create context menu for my extension, which will do something when I click on it. So, following google documentation i create parent. chrome.contextMenus.create({title: "bla", id: "parent"}); Then I create child and try to add onclick handler to it. chrome.contextMenus.create({ title: "bla bla", parentId: "parent", id: "child", onclick : function() { alert("bla bla bla") } }); So, its works fine without onclick, and not works

Erratic behavior of executeScript: “Cannot access a chrome:// URL” on http://www.imdb.com/list

百般思念 提交于 2019-12-18 07:18:18
问题 I'm executing content scripts on some http://www.imdb.com/list... specific urls. It works fine most of the time, but sometimes it's not. Then I reload the page with F5, and again, it works well most of the time. In an event page I listen for onDOMContentLoaded chrome.webNavigation.onDOMContentLoaded.addListener(listener, {'url': urlFilter}); The listener hangs well. function listener(tab){ t=tab; chrome.tabs.executeScript(tab.id, {file: 'elementoWeb 2.1.js'}, function(resultado){ if(chrome

Erratic behavior of executeScript: “Cannot access a chrome:// URL” on http://www.imdb.com/list

十年热恋 提交于 2019-12-18 07:18:09
问题 I'm executing content scripts on some http://www.imdb.com/list... specific urls. It works fine most of the time, but sometimes it's not. Then I reload the page with F5, and again, it works well most of the time. In an event page I listen for onDOMContentLoaded chrome.webNavigation.onDOMContentLoaded.addListener(listener, {'url': urlFilter}); The listener hangs well. function listener(tab){ t=tab; chrome.tabs.executeScript(tab.id, {file: 'elementoWeb 2.1.js'}, function(resultado){ if(chrome

Chrome Extension: Remembering a checkbox value when popup is reopened

倖福魔咒の 提交于 2019-12-18 07:10:34
问题 Newbie here so sorry if this is pretty elementary. I'm making an extension that simply has a checkbox/switch when loaded. It is to be unchecked the first time you open it but when the extension is closed and reopened, I would like it to display whether it was checked or not. The checkbox starts a timer in the background.js and unchecking it stops it. I have all this working, except to save the state of the checkbox Relevant HTML for the popup <div class="onoffswitch"> <input type="checkbox"

How to use webrtc insde google chrome extension?

岁酱吖の 提交于 2019-12-18 07:05:42
问题 I have developped a google chrome extension. I am trying now to integrate webRTC feature inside: navigator.getUserMedia = navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia; console.log("step1"); navigator.getUserMedia({audio: true, video: true}, function(stream){ console.log("step2"); $('#myVideo').prop('src', URL.createObjectURL(stream)); window.localStream = stream; console.log("step3"); }, function(error){ console.log(error); }); I got an error: step1

chrome.browserAction.onClicked.addListener() with popup

风格不统一 提交于 2019-12-18 05:57:10
问题 I want to add Listener to the event which fires, everytime the browser icon is clicked. I have also a popup which comes up on click on this icon. I tried chrome.browserAction.onClicked.addListener() but didnot get it fired, later i saw that the doc says: Fired when a browser action icon is clicked. This event will not fire if the browser action has a popup. so, I have popup, so this Listener doesnot work. What workaround can I do to attach Listener to icon in my case? 回答1: There is no

How to close the current extension tab?

杀马特。学长 韩版系。学妹 提交于 2019-12-18 05:34:32
问题 I'm trying to close the Options page of the extension. I have a Cancel button and I'm using this code: chrome.tabs.getCurrent(null, function(tab) { chrome.tabs.remove(tab.id, function() {}); }); When I'm trying to use it, it always gives this error: Uncaught TypeError: Cannot call method 'getCurrent' of undefined What's wrong with the code? 回答1: It works for me with one little fix: chrome.tabs.getCurrent(function(tab) { chrome.tabs.remove(tab.id, function() { }); }); Just make sure you're

Chrome Extension which is supposed to run on all Facebook pages only runs when I hit refresh

爱⌒轻易说出口 提交于 2019-12-18 05:18:07
问题 This is my first hack at writing a Chrome extension. I want it to execute some pretty simple JavaScript every time a Facebook page loads. It's doing everything I want except that for some reason, it only runs my script if I hit the Refresh button. If, e.g. I clicked on the Facebook logo, or I go to a status from my notifications, the script doesn't run... until I click refresh. Here is my manifest: { "name": "Anti-social Reader", "version": "1.0", "description": "Defeats 'social reader' apps

Options-enabled content-script Chrome extension without background page?

喜夏-厌秋 提交于 2019-12-18 05:14:17
问题 I'm making a content script extension for Google Chrome, it adds functionality to a website's page. I want to add a couple of options, not big deal really, I'd just need two strings (none of which are sensitive user data). From this answer, I assume I need a background page, which I'd rather not add to my extension - I don't want it to gain unnecessary weight. Do I really need a background page, or I could have an options page without it (and which storage could I use)? 回答1: UPDATE As of

open multiple tabs on a single window by a single click using JavaScript

。_饼干妹妹 提交于 2019-12-18 05:14:15
问题 I need to open multiple tabs on a single window, new window instance for a single link will not be a problem but when it comes to 20+ (which is my case) then 20+ new windows are really a problem, so I need to find a solution, the code has to run on chrome only in my case I have 35 links stored in an array. I am reading array using a for loop and opening links in new tabs using window.open() I can use only JavaScript for this. I am developing a customized chrome extension. I found out that