google-chrome-extension

Get current page URL in Chrome extension

只愿长相守 提交于 2019-12-23 10:55:14
问题 I want to get the current page URL from my default_popup page like this: chrome.tabs.query({active:true},function(tab){ url = tab.url; }); And I have registered this popup.html page in the manifest.json file. Yet I am getting the error message: Uncaught Type Error: Cannot call method 'query' of undefined What am I doing wrong? 回答1: The callback parameter should specify a function that looks like this: function(array of Tab result){...} Maybe you should write like this url = tab[0].url; 回答2:

Removing permissions of the extensions

空扰寡人 提交于 2019-12-23 10:26:05
问题 I have an extension that first asks for permissions to access Google Drive files. The extension is almost empty except in the popup I load this js: chrome.identity.getAuthToken({ 'interactive': true }, function(token) { // Use the token. console.log('Request Token') console.log(token) chrome.identity.removeCachedAuthToken( { 'token': token }, function () {}) console.log('Removed token') }); In my manifest I have valid key, oauth2 client id, and "scopes":["https://www.googleapis.com/auth/drive

createHTMLNotification() replacement

折月煮酒 提交于 2019-12-23 09:40:09
问题 I created a Chrome extension in which it uses createHTMLNotification() to show a window on top of everything. However, starting from Chrome 28 Google decided to drop createHTMLNotification() entirely (why, Google. Why?). All in a sudden I need to find a replacement. createHTMLNotification() let me to dynamically change things on the notification. However, I don't think the new Rich Notification let me do that. Is there any work-around or suggestions? Thanks. 回答1: The change was actually

Chrome Inline Install for extension not working

最后都变了- 提交于 2019-12-23 09:28:31
问题 I'm trying to use the new chrome inline install feature for extensions (see here: http://code.google.com/chrome/webstore/docs/inline_installation.html). I can't get it to work unfortunately, and have very little clues to go by. I've added the link element to the head element <link rel="chrome-webstore-item" href="https://chrome.google.com/webstore/detail/pnnfemgpilpdaojpnkjdgfgbnnjojfik"> and I call chrome.webstore.install(); in a jquery event handler. I've also verified my domain, however, I

What is the “shell” window type in chrome extensions? Can it be used to hide a window?

守給你的承諾、 提交于 2019-12-23 09:19:38
问题 I just noticed this in the trunk/dev channel: type ( enumerated string ["normal", "popup", "panel", "app", "shell"] ) The type of browser window this is. I tried it with with Canary: no window is shown, but we have console output, so something has been created. The thing is I just don't get it. How is this different from a background page? I was hoping to toggle windows completely out of the user's view, without having to reload the window's content when toggling up. Anyway, I'm not hoping

Service Worker TypeError when opening Chrome extension

。_饼干妹妹 提交于 2019-12-23 09:11:31
问题 My service worker is throwing this error in Chrome when I open the WAVE (Web Accessibility Evaluation Tool) extension: Uncaught (in promise) TypeError: Request scheme 'chrome-extension' is unsupported at sw.js:52 (anonymous) @ sw.js:52 Promise.then (async) (anonymous) @ sw.js:50 Promise.then (async) (anonymous) @ sw.js:45 Promise.then (async) (anonymous) @ sw.js:38 My service worker code is: (function () { 'use strict'; var consoleLog; var writeToConsole; const CACHE_NAME = '20180307110051';

Using javascript to access Google's URL shortener APIs in a Google Chrome extension

穿精又带淫゛_ 提交于 2019-12-23 09:04:09
问题 I am writing my first google chrome extension which will use Google's URL shortener api to shorten the URL of the currently active tab in Chrome. I am a longtime sw developer (asm/C++) but totally new to this "webby" stuff. :) I can't seem to figure out how to make (and then process) the http POST request using js or jquery. I think I just don't understand the POST mechanism outside of the curl example. My javascript file currently looks like this: chrome.browserAction.onClicked.addListener

How to share code between content script and addon?

↘锁芯ラ 提交于 2019-12-23 08:54:04
问题 I'm writing an extension for Firefox 4+. I have some code in a file named utils.js which I'd like to call from both the addon's main.js and from the page-mod 's content script. Is it possible to refer from both to the same utils.js ? If so, how? Edit: Even better would be a solution allowing me to use the same code in a Google Chrome extension, too. 回答1: I've run into this same problem. You'd think there'd be an obvious solution. Here's what I've been doing for firefox (haven't worked with

Does the jQuery $(window).load(); event not fire on pages without a <!DOCTYPE> declaration? (…in a chrome extension content script)

前提是你 提交于 2019-12-23 08:00:03
问题 I'm working on a Google Chrome extension that manipulates a webpage, but after it is either partially loaded (the DOM) or fully loaded (with images). It seems that many sites nowadays use the <!DOCTYPE html> declaration, or some variation of it, but many others do not. The question is mainly about HTML doctypes...I'm not sure about the others. Is it safe to assume that if a webpage does not have the DOCTYPE declaration, then $(window).load(); will not be fired? In the beginning I was using $

Is it possible for a Chrome extension to access an IndexedDB database created by a specific domain?

随声附和 提交于 2019-12-23 07:49:17
问题 If http://example.com/ creates an IndexedDB database, is it possible for a Chrome extension (used on domains other than example.com ) to open and query this database? 回答1: No, you can not do it. The data storage is sandboxed http://www.html5rocks.com/en/tutorials/offline/storage/ 来源: https://stackoverflow.com/questions/13453418/is-it-possible-for-a-chrome-extension-to-access-an-indexeddb-database-created-by