google-chrome-extension

Response function not working in popup.js chrome extension

跟風遠走 提交于 2021-01-07 02:41:11
问题 I'm making a small chrome extension. Right now I'm checking for website language and trying to show that language in popup.html but response function is not working and I'm unable to show language in popup. Any help? popup.html <!DOCTYPE html> <html> <head></head> <body> <h1>Popup</h1> <script src="./scripts/popup.js"></script> </body> </html> popup.js chrome.runtime.sendMessage({type: "getLanguage"}, function(selectedLanguage) { // This function is not working if(typeof selectedLanguage ==

Chrome Extension/Javascript - Iterate through an array of URLs and Fetch DOM for each

点点圈 提交于 2021-01-07 01:25:10
问题 I was wondering if anyone might be able to help me out? I am trying to write a Google Chrome Extension that loops through an array of URL's and grabs the DOM for each and outputs it somewhere (here just the console). Ideally I'd like this all to be done in the background rather than having to update the active tab... but not sure if this is possible - maybe for another question perhaps... For now though, my problem is that it will only fetch the DOM of the last URL in the array and ignores

Activate popup.html from Content Script: Chrome Extension Development

戏子无情 提交于 2021-01-04 06:45:07
问题 My current project requires opening/activating popup.html (browserAction) from content script? I have read a few answers that say, it's not possible because of security concern. E.g Ans: How can I open my extension's pop-up with JavaScript? If that's the case, then how Chrome Bookmark Manager extension does it when CTRL+D shortcut is pressed? Ref: Bookmark Manager Extension 回答1: They're just using the commands interface, with an event name of _execute_page_action (or _execute_browser_action )

Activate popup.html from Content Script: Chrome Extension Development

丶灬走出姿态 提交于 2021-01-04 06:45:06
问题 My current project requires opening/activating popup.html (browserAction) from content script? I have read a few answers that say, it's not possible because of security concern. E.g Ans: How can I open my extension's pop-up with JavaScript? If that's the case, then how Chrome Bookmark Manager extension does it when CTRL+D shortcut is pressed? Ref: Bookmark Manager Extension 回答1: They're just using the commands interface, with an event name of _execute_page_action (or _execute_browser_action )

Save json to chrome storage / local storage

徘徊边缘 提交于 2021-01-02 06:42:13
问题 I want to save json to chrome or local storage. I also need to be able too add items without losing the others. 回答1: Updated var local = (function(){ var setData = function(key,obj){ var values = JSON.stringify(obj); localStorage.setItem(key,values); } var getData = function(key){ if(localStorage.getItem(key) != null){ return JSON.parse(localStorage.getItem(key)); }else{ return false; } } var updateDate = function(key,newData){ if(localStorage.getItem(key) != null){ var oldData = JSON.parse

Make Promise wait for a Chrome.runtime.sendMessage

帅比萌擦擦* 提交于 2021-01-02 05:41:34
问题 I've always seen Promise work with setTimeout, but I'm trying to make it based on whatever the chrome.runtime.sendMessage returns to the Promise. I've got a content script that does this function once the script has been done. chrome.runtime.sendMessage({complete: true}); I've got a background script that loops through every item in an array and uses one of its values to open a URL with chrome.tabs.update. What I'm trying to do is make the async function wait for the Message the content

Make Promise wait for a Chrome.runtime.sendMessage

a 夏天 提交于 2021-01-02 05:38:48
问题 I've always seen Promise work with setTimeout, but I'm trying to make it based on whatever the chrome.runtime.sendMessage returns to the Promise. I've got a content script that does this function once the script has been done. chrome.runtime.sendMessage({complete: true}); I've got a background script that loops through every item in an array and uses one of its values to open a URL with chrome.tabs.update. What I'm trying to do is make the async function wait for the Message the content

background.html vs. background.js - chrome extension

六眼飞鱼酱① 提交于 2021-01-02 05:22:33
问题 I am really confused here. I am trying to understand the file architecture of chrome extension. I am reading this doc: https://developer.chrome.com/extensions/overview#arch My situation: I want to setup the oauth flow so that user can log in inside the extension (the other endpoint is my django backend). Till now, I have these files: background.js content.js popup.html manifest.json where my content.js sends message to background.js and gets response back. so far so fine! But now while

Chrome extension: Insert fixed div as UI

百般思念 提交于 2020-12-29 03:48:05
问题 I want to insert a div into a fixed position using a chrome extension. It will overlay the page that you are currently viewing. My concern is that I want this to work on any page without altering it (other than inserting my fixed div), but I don't know if that is possible with the way that I'm doing it. Currently, the button won't show up, and I had a lot of trouble getting the div to show up. By the way, the positioning is just temp for now, I will position it correctly once I get it on the

Chrome extension: Insert fixed div as UI

≡放荡痞女 提交于 2020-12-29 03:45:50
问题 I want to insert a div into a fixed position using a chrome extension. It will overlay the page that you are currently viewing. My concern is that I want this to work on any page without altering it (other than inserting my fixed div), but I don't know if that is possible with the way that I'm doing it. Currently, the button won't show up, and I had a lot of trouble getting the div to show up. By the way, the positioning is just temp for now, I will position it correctly once I get it on the