google-chrome-extension

Chrome Extension with Database API interface

对着背影说爱祢 提交于 2019-12-13 08:11:49
问题 I want to update a div with a list of anchors that I generate from a local database in chrome. It's pretty simple stuff, but as soon as I try to add the data to the main.js file via a callback everything suddenly becomes undefined. Or the array length is set to 0. ( When it's really 18. ) Initially, I tried to install it into a new array and pass it back that way. Is there a setting that I need to specify in the chrome manifest.json in order to allow for communication with the database API? I

Issue opening new tab in multiple functions in Javascript for Chrome Extension

微笑、不失礼 提交于 2019-12-13 08:07:42
问题 I am working on a Chrome extension, but for some reason I am able to create a new tab only in a single function and not in multiple functions. Code- function editorial() { chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ var tab_url=tabs[0].url; var new_url=tab_url.slice(11); chrome.tabs.create({ url:"http://www.discuss." + new_url}); }); } document.addEventListener('DOMContentLoaded', function () { var btn = document.getElementById('viewEditorial'); if (btn) { btn

Save last session of chrome extension

雨燕双飞 提交于 2019-12-13 08:07:18
问题 In my html file I have a simple table and a couple of buttons that allow adding/removing rows. If I store that html in popup.html, then every time I close chrome extension the session disappears. That is if I added some rows and put some values to the cells of that table, once I go from my extension, these rows and values disappear when I click on the extension again. As a solution I saw putting that html to background.html and retrieving that code from popup.js: // listeners to save/restore

Chrome extension fires multiple times on one page

本秂侑毒 提交于 2019-12-13 08:03:06
问题 I'm trying to wrap my head around how these extensions work. Right now I'm sending a message from content script to the background. I tried both single messages and a long-lived connection. For each page, the console registers multiple logs...and I have no idea why. The scripts are simple: content.js chrome.runtime.sendMessage({hi: "hi"}, function(response) {}); //or //var port = chrome.runtime.connect({name: "test"}); //port.postMessage({hi: "hi"}); background.js chrome.runtime.onMessage

How to make a static HTML as a chrome extension?

跟風遠走 提交于 2019-12-13 07:57:19
问题 I want to make a Chrome extension basically constituted as a HTML bar staying at the top of the user window all the time (after he activates it). The bar position would be something "like" it: My question is: how can I achieve this behavior? I thinked about adding it as "browser action"at the manifest, but it does not fits since it disappears when loses focus. I also tried to add it as a content script , "embracing" my HTML with simple JS command document.write(HTML line) , but I can see no

How to periodically check whether a tab is created or not, just when the chrome extension is installed

£可爱£侵袭症+ 提交于 2019-12-13 07:55:41
问题 I have set my website as a chrome extension.Presently when I click on the extension icon,it navigates to website's login page.And it access a server file and set's the color of the icon according to the output of the server file.Now what I need is that,all these action is performed when the extension icon is clicked.I want these actions to be performed just when the extension is installed in chrome.It should be checked periodically whether there is output from the server file,just when the

Get and store auth_token in chrome extension

為{幸葍}努か 提交于 2019-12-13 07:52:00
问题 I am implementing a chrome extension. Where an user log in(email and password) and get auth token from 3rd party. I want to store this auth token so when sending another request to same party I can use this token. What is good approach to do this. Should I store it ? If yes how? Else what should I do? 回答1: you can save it in Storage Step 1 :- You need to add the permission in menifist , json "permissions": [ "storage" ], Steps 2 :- Set token to the storage chrome.storage.local.set({ "auth

Modifying DOM of a html page from background javascript

家住魔仙堡 提交于 2019-12-13 07:48:25
问题 How do I modify DOM html page from background script? The html page exists in the extension's root folder. When then page is opened the URL is looked like "chrome-extension://hffffemnacblbojccelnkhnafndfkhgc/block.html" File tree in my extension: css/ bootstrap-theme.css bootstrap-theme.css.map bootstrap-theme.min.css bootstrap.css bootstrap.css.map bootstrap.min.css popup.css fonts/ img/ 128-128.png 1413232635_virus detected 2.png 16-16.png 48-48.png js/ block.js bootstrap.js bootstrap.min

How to restrict the size of a Google chrome extension popup?

╄→尐↘猪︶ㄣ 提交于 2019-12-13 07:41:46
问题 I am creating a Google Chrome extension that does some basic search based on the choices provided. This is how it looks so far The problem is that there is a lot of white space on the sides which does not look good, especially because this is a popup and overlays on the current page. How can I make sure that the popup uses the minimum amount of space required? 回答1: It should be as simple as styling the body element. Do you want a fixed size, fixed width, or just less margins? For fixed size,

How to restirict chrome to add only one contextmenu?

寵の児 提交于 2019-12-13 07:25:56
问题 I have created context menu & its child menus for selection of text using chrome.contextMenus.create but it creates multiple menus & sub-menus while testing. Can you tell me what is the prblem. I am using code to create menus : var contexts=["selection"]; var context = contexts[0]; var title = "Parent"; var id = chrome.contextMenus.create({"title": title, "contexts":[context]},function (){ var child1 = chrome.contextMenus.create({"title": "child1", "contexts":[context], "parentId": id,