google-chrome-extension

How to store Set object in chrome local storage

帅比萌擦擦* 提交于 2021-01-20 04:59:00
问题 var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage.local.set( { 'key': testSet }, function() { chrome.storage.local.get( 'key', function(data){ console.log(data) }); }); This outputs Object {key: Object} key: Object__proto__: Object__proto__: Object Why doesn't it show the testSet values in there? 回答1: One way to achieve this, is by converting your Set into an array by using Spread Operator. E.g. var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage

How to store Set object in chrome local storage

吃可爱长大的小学妹 提交于 2021-01-20 04:58:09
问题 var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage.local.set( { 'key': testSet }, function() { chrome.storage.local.get( 'key', function(data){ console.log(data) }); }); This outputs Object {key: Object} key: Object__proto__: Object__proto__: Object Why doesn't it show the testSet values in there? 回答1: One way to achieve this, is by converting your Set into an array by using Spread Operator. E.g. var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage

How to store Set object in chrome local storage

不问归期 提交于 2021-01-20 04:58:07
问题 var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage.local.set( { 'key': testSet }, function() { chrome.storage.local.get( 'key', function(data){ console.log(data) }); }); This outputs Object {key: Object} key: Object__proto__: Object__proto__: Object Why doesn't it show the testSet values in there? 回答1: One way to achieve this, is by converting your Set into an array by using Spread Operator. E.g. var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage

How to store Set object in chrome local storage

◇◆丶佛笑我妖孽 提交于 2021-01-20 04:57:08
问题 var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage.local.set( { 'key': testSet }, function() { chrome.storage.local.get( 'key', function(data){ console.log(data) }); }); This outputs Object {key: Object} key: Object__proto__: Object__proto__: Object Why doesn't it show the testSet values in there? 回答1: One way to achieve this, is by converting your Set into an array by using Spread Operator. E.g. var testSet = new Set(); testSet.add(1); testSet.add(2); chrome.storage

How to redirect current tab's url in Chrome extension?

不羁岁月 提交于 2021-01-20 04:15:41
问题 I'm writing a Chrome extension, used to switch between different search engines. The manifest.json looks like: { "browser_action": { "default_popup": "popup.html" }, "permissions": [ "tabs", "activeTab" ], "content_security_policy": "script-src 'self'; object-src 'self'", "content_scripts": [{ "matches": ["*://*.baidu.com/*"], "js": ["content.js"] }] } content.js is used to get user's keywords in searching. popup.html contains a list of supported search engines. When user clicks on search

How to redirect current tab's url in Chrome extension?

一曲冷凌霜 提交于 2021-01-20 04:14:20
问题 I'm writing a Chrome extension, used to switch between different search engines. The manifest.json looks like: { "browser_action": { "default_popup": "popup.html" }, "permissions": [ "tabs", "activeTab" ], "content_security_policy": "script-src 'self'; object-src 'self'", "content_scripts": [{ "matches": ["*://*.baidu.com/*"], "js": ["content.js"] }] } content.js is used to get user's keywords in searching. popup.html contains a list of supported search engines. When user clicks on search

How to redirect current tab's url in Chrome extension?

核能气质少年 提交于 2021-01-20 04:12:51
问题 I'm writing a Chrome extension, used to switch between different search engines. The manifest.json looks like: { "browser_action": { "default_popup": "popup.html" }, "permissions": [ "tabs", "activeTab" ], "content_security_policy": "script-src 'self'; object-src 'self'", "content_scripts": [{ "matches": ["*://*.baidu.com/*"], "js": ["content.js"] }] } content.js is used to get user's keywords in searching. popup.html contains a list of supported search engines. When user clicks on search

'Access to fetch has been blocked by CORS policy' Chrome extension error

风格不统一 提交于 2021-01-07 03:13:15
问题 I know this has been asked many times, but it seems to me that I've done all the right things and still can't get it working. I am trying to get data from an external API from the background script of my Chrome extension, using messaging to initiate the call from the content script and get the results. I have no control over the external API. The documentation from that API says to use script tags to get a jsonp response, but if I understand correctly, that shouldn't matter when the below

'Access to fetch has been blocked by CORS policy' Chrome extension error

断了今生、忘了曾经 提交于 2021-01-07 03:12:34
问题 I know this has been asked many times, but it seems to me that I've done all the right things and still can't get it working. I am trying to get data from an external API from the background script of my Chrome extension, using messaging to initiate the call from the content script and get the results. I have no control over the external API. The documentation from that API says to use script tags to get a jsonp response, but if I understand correctly, that shouldn't matter when the below

Response function not working in popup.js chrome extension

情到浓时终转凉″ 提交于 2021-01-07 02:45:56
问题 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 ==