google-chrome

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

The meaning of “'x' is not a function or its return value is not iterable” error

自作多情 提交于 2021-01-20 04:17:39
问题 I accidentally witnessed that this causes an error in V8 (Chrome, Node.js, etc): for (let val of Symbol()) { /*...*/ } TypeError: Symbol is not a function or its return value is not iterable It appears that any other non-iterable value (including a function) causes another error: for (let val of function () { throw 'never called' }) { /*...*/ } TypeError: (intermediate value) is not iterable As the reference states, the error is specific to Chrome: TypeError: 'x' is not a function or its

The meaning of “'x' is not a function or its return value is not iterable” error

被刻印的时光 ゝ 提交于 2021-01-20 04:16:00
问题 I accidentally witnessed that this causes an error in V8 (Chrome, Node.js, etc): for (let val of Symbol()) { /*...*/ } TypeError: Symbol is not a function or its return value is not iterable It appears that any other non-iterable value (including a function) causes another error: for (let val of function () { throw 'never called' }) { /*...*/ } TypeError: (intermediate value) is not iterable As the reference states, the error is specific to Chrome: TypeError: 'x' is not a function or its

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

getCurrentPosition in JS does not work on iOS

旧巷老猫 提交于 2021-01-19 22:28:36
问题 I have a page that contains a code that gets the current location from the device and load other stuff based on the location with this code: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(successFunction); } else { // Make API call to the GeoIP services } It works on all android devices that I tested, but on iOS and macOS, it’s not working. Neither if nor else . Seems like it stuck at getting the current location. Any help? 回答1: iOS and macOS doesn't give you the user's

getCurrentPosition in JS does not work on iOS

梦想的初衷 提交于 2021-01-19 22:25:17
问题 I have a page that contains a code that gets the current location from the device and load other stuff based on the location with this code: if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(successFunction); } else { // Make API call to the GeoIP services } It works on all android devices that I tested, but on iOS and macOS, it’s not working. Neither if nor else . Seems like it stuck at getting the current location. Any help? 回答1: iOS and macOS doesn't give you the user's

Why does selenium chromedriver use less resources than regular chrome

删除回忆录丶 提交于 2021-01-18 06:12:25
问题 I have noticed that when launching chrome with fresh user data directories via selenium chromedriver it is using up much less resources (cpu, memory, and disk) than when launching normally. One of the reasons I was able to find out was that selenium chromedriver launches with these arguments: --disable-background-networking --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --disable-web