0
我正在爲reddit.com構建Chrome擴展,因此我正在使用page action
。現在我想page_action icon
只爲特定的URL格式是可見的,即針對特定網址的隱藏頁面操作
http://www.reddit.com [allowed]
http://www.reddit.com/r/* [allowed]
http://www.reddit.com/r/books/comments/* [not allowed]
所以,正如我上面提到的,我不希望我的擴展頁面操作圖標是涉及comments url of redddit
的3rd case
可見。
目前我使用下面的代碼在我background.js
來實現這一目標:
function check(tab_id, data, tab){
if(tab.url.indexOf("reddit.com") > -1 && tab.url.indexOf("/comments/") == -1){
chrome.pageAction.show(tab_id);
}
};
chrome.tabs.onUpdated.addListener(check);
我還增加了以下線在我manifest.json
禁用評論頁面
"exclude_matches": ["http://www.reddit.com/r/*/comments/*"],
上延伸所以,我的問題是這是禁用&隱藏特定頁面/網址的擴展的正確/理想方式?