Skip to content

Instantly share code, notes, and snippets.

@takatama
Last active Jan 1, 2016
Embed
What would you like to do?
A template for page action extension.
var urlRegExp = new RegExp('^https?://www.google.com/maps/preview'); // アドレスバーの横にアイコンを表示するときのURL正規表現
function showIcon(tabId, changeInfo, tab) {
if (tab.url.match(urlRegExp)) {
chrome.pageAction.show(tabId);
}
}
chrome.tabs.onUpdated.addListener(showIcon);
chrome.pageAction.onClicked.addListener(function(tab) {
chrome.tabs.executeScript(tab.id, {
"file": "execute.js" //実行したいスクリプトのファイル名 (execute.js)
}, function () {
if (chrome.runtime.lastError) {
console.error(chrome.runtime.lastError.message);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment