挿入するコンテンツ スクリプトを作成することもできますが、変数に格納するだけなので簡単です。chrome.tab API を参照することをお勧めします。Google は開発者向けに API の文書化を非常にうまく行っているからです。
バックグラウンド ページで:
var REDIRECTION_SCRIPT_A = "window.location.href='http://www.google.com'";
var REDIRECTION_SCRIPT_B = "window.location.href='http://bit.ly/m2TXqC'";
var toGoogle = true;
var intervalId;
chrome.browserAction.onClicked.addListener(function() {
clearInterval(intervalId);
});
// Execute redirection script on current page
// Note that you can select any tab based on its ID by replacing
// null below
function annoyUser() {
console.log("test");
chrome.tabs.executeScript(null, {code:
(toGoogle ? REDIRECTION_SCRIPT_A : REDIRECTION_SCRIPT_B) });
toGoogle = !toGoogle;
}
// Do once a minute ad infinitum
intervalId = setInterval(annoyUser, 5000);
manifest.json で:
{
...
"permissions": ["http://*/*", "tabs"],
...
}