Skip to content

Instantly share code, notes, and snippets.

@VEINHORN
Last active August 29, 2015 14:20
Show Gist options
  • Save VEINHORN/9c36cf92aad970d64bf5 to your computer and use it in GitHub Desktop.
Save VEINHORN/9c36cf92aad970d64bf5 to your computer and use it in GitHub Desktop.
var requestCallback;
chrome.storage.sync.get({
redirect_domain : "zerx.co",
domain_checking_interval : 5000
}, function(items) {
console.log(items.domain_checking_interval);
setInterval(function() {
console.log('Domain name updated.');
check_domain();
if (typeof requestCallback === "function") {
chrome.webRequest.onBeforeRequest.removeListener(requestCallback);
requestCallback = null;
}
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
//requestCallback = this;
redirected_url = "http://" + items.redirect_domain;
console.log("Redirected to: " + redirected_url);
return {redirectUrl: redirected_url};
},
{
urls: ["http://zerx.co/*"],
types: ["main_frame"]
},
["blocking"]
);
}, items.domain_checking_interval);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment