google-chrome-extension

Edit Content Security Policy in onHeadersReceived

假如想象 提交于 2021-01-28 06:37:29
问题 I'm developing a small chrome extension for myself to embed an iframe into the website. Content Security Policy makes this difficult, since the frame-src directive on a few websites doesn't allow my content to be loaded. The error message is the following: Refused to frame 'mydomain' because it violates the following Content Security Policy directive: "frame-src someotherdomain". So far, I have tried adding my host to the frame-src directive and to the frame-ancestors in webRequest

Access Chrome clipboard events with extension

被刻印的时光 ゝ 提交于 2021-01-28 06:12:03
问题 I want to copy the system clipboard data in my extension; I am able to get the events for copy, cut and paste of my extension, bt I want to get the event when ever system clipboard changes. How can I do this? 回答1: In general, you cannot. There is no event that indicates that SOMEWHERE in the system the clipboard was updated. An imperfect solution would be to inject content scripts in all pages and listen to events in them. This will only work for copy/cut of the content of the pages

chrome.tabs.query callback in angular not refreshing view

独自空忆成欢 提交于 2021-01-28 06:08:50
问题 I have created a simple extension for Chrome using angular-cli. I want the extension's popup to display the URL of the current tab. However the view does not seem to get updated when setting a property from chrome.tabs.query callback. I have confirmed with a console.log that the callback is getting called and the correct URL is being returned. What am I doing wrong? app.component.ts import { Component } from '@angular/core'; @Component({ selector: 'app-root', templateUrl: './app.component

How to use Google Analytics in Chrome Extension?

六月ゝ 毕业季﹏ 提交于 2021-01-28 05:46:11
问题 This official tutorial seems outdated because ga.js is deprecated according to this. Besides, in the tutorial it has: _gaq.push(['_setAccount', 'UA-XXXXXXXX-X']); but UA-XXX-X is property ID not account ID. The latest seems to be analytics.js I tried this solution but it doesn't work for me. I saw error Refused to load the script 'https://www.google-analytics.com/analytics.js' because it violates the following Content Security Policy directive: "script-src 'self' https://www.googletagmanager

Open new tab from chrome extension

烂漫一生 提交于 2021-01-28 05:17:57
问题 I wanna create a chrome extension that when you click it that you open my website. But how? I tried searching on google but this is all what I could create: { "name": "My First Extension", "version": "1.0", "description": "The first extension that I made.", "browser_action": { "default_icon": "icon.png" chrome.tabs.create({'url': chrome.extension.getURL('popup.html')}, function(tab) { // Tab opened. }); }, "permissions": [ "http://api.flickr.com/" ] } But this doesn't seem to work. 回答1: The

How to delete Proxy-Authorization Cache on Chrome extension?

限于喜欢 提交于 2021-01-28 04:51:43
问题 I am building a "proxy client" extension for chrome and i have following scenario: Users can login to the extension and get a token from API. Tokens are valid for 2 hours. After login users can select a proxy server from a list and that proxy is set with chrome.proxy api. I am using Squid on proxy servers. When a user connects to a proxy server and lands on onAuthRequired i return email and token as authCredentials. Chrome uses those credentials from cache until token is not valid anymore and

How to implement “return true;”? Error: “The message port closed before a response was received.”

倾然丶 夕夏残阳落幕 提交于 2021-01-28 04:50:52
问题 How can I implement that my event-handler returns true ? (Tried everything but the error returns) I'm getting following error: "Unchecked runtime.lastError: The message port closed before a response was received." Solution is: "Note: The sendResponse callback is only valid if used synchronously, or if the event handler returns true to indicate that it will respond asynchronously. The sendMessage function's callback will be invoked automatically if no handlers return true or if the

Chrome extension: Get last used tab

ぃ、小莉子 提交于 2021-01-28 04:47:45
问题 I'm trying to create a simple plugin for Google Chrome. One of the functions would be a return to the last used tab, but I don't know how to do it. So, is there any way to get the last used tab? 回答1: You could try adding a hook into the onSelected event of the tabs and just saving that variable... soemthing like this: var curTabID = 0; var curWinID = 0; chrome.tabs.onSelectionChanged.addListener(function(tabId, selectInfo) { curTabID = tabId; curWinID = selectInfo.windowId; }); Then you have

pause a download with chrome doesnt work as expected

半腔热情 提交于 2021-01-27 21:39:51
问题 I am trying to puase a download but it doesnt work, the file is downloaded. here my code: In my background script: chrome.downloads.onCreated.addListener(function (e) { chrome.downloads.pause(e.id); }); Here chrome.downloads.pause the API documentation 来源: https://stackoverflow.com/questions/63500467/pause-a-download-with-chrome-doesnt-work-as-expected

Access all new Chrome Notifications programmatically

梦想的初衷 提交于 2021-01-27 19:57:09
问题 I have no previous experience with programming Google Chrome plugins which is why I am starting here to see if what I want to accomplish is possible/reasonable. I do however have a pretty broad experience in programming in general. What I want: I want some kind of "trigger" to go off when a new Chrome Notification (you know these little pop ups above the system tray) is popping up. I want to execute some script/code depending on what information the notification contains so that I for example