chrome 获取同步存储的多个值的扩展索引
chrome extension indexof multiple value from get sync storage
请帮助解决这个 1 周的问题:我想 search/index 选项卡 url 来自多个值。
我只想 运行 根据用户在选项页面上输入的 url 在特定网站上扩展。非常感谢您的帮助
我的手动代码:
array = ["google", "yahoo", "facebook"];
chrome.webNavigation.onCompleted.addListener(function(details) {
chrome.tabs.getSelected(null, function(tab) {
if (tab.url.indexOf("google") > -1 ) {
"run extension code"
}
if (tab.url.indexOf("yahoo") > -1 ) {
"run extension code"
}
if (tab.url.indexOf("facebook") > -1 ) {
"run extension code"
}});
});
请帮助我运行自动执行此操作并从存储选项中获取同步。
我的问题得到了解决。我通过自己的研究解决了它。十分感谢你的帮助。这正是我想要的。
var myurl = ["yahoo", "google", "bing"];
chrome.webNavigation.onCompleted.addListener(function(details) {
chrome.tabs.getSelected(null, function(tab) {
for (var i = 0, icount = myurl.length; i < icount; i++) {
if (tab.url.indexOf(myurl[i]) > -1) {
"run code to enable extension"
break; // halt for loop
}
};
});
});
请帮助解决这个 1 周的问题:我想 search/index 选项卡 url 来自多个值。
我只想 运行 根据用户在选项页面上输入的 url 在特定网站上扩展。非常感谢您的帮助
我的手动代码:
array = ["google", "yahoo", "facebook"];
chrome.webNavigation.onCompleted.addListener(function(details) {
chrome.tabs.getSelected(null, function(tab) {
if (tab.url.indexOf("google") > -1 ) {
"run extension code"
}
if (tab.url.indexOf("yahoo") > -1 ) {
"run extension code"
}
if (tab.url.indexOf("facebook") > -1 ) {
"run extension code"
}});
});
请帮助我运行自动执行此操作并从存储选项中获取同步。
我的问题得到了解决。我通过自己的研究解决了它。十分感谢你的帮助。这正是我想要的。
var myurl = ["yahoo", "google", "bing"];
chrome.webNavigation.onCompleted.addListener(function(details) {
chrome.tabs.getSelected(null, function(tab) {
for (var i = 0, icount = myurl.length; i < icount; i++) {
if (tab.url.indexOf(myurl[i]) > -1) {
"run code to enable extension"
break; // halt for loop
}
};
});
});