Skip to content

Instantly share code, notes, and snippets.

@SebastianJay
Last active April 13, 2017 00:46
Show Gist options
  • Save SebastianJay/909e830c25d7a79901b8b4723819d672 to your computer and use it in GitHub Desktop.
Save SebastianJay/909e830c25d7a79901b8b4723819d672 to your computer and use it in GitHub Desktop.
Chrome extension for URL redirection
// credit http://stackoverflow.com/a/4859938
chrome.runtime.onMessage.addListener(function(request, sender) {
chrome.tabs.update(sender.tab.id, {url: request.redirect});
});
{
"manifest_version": 2,
"name": "URL Redirection",
"version": "0.1",
"content_scripts": [
{
"matches": [
"https://www.yahoo.com"
],
"js": ["redirect.js"]
}
],
"background": {
"scripts": ["background.js"],
"persistent": false
}
}
// credit http://stackoverflow.com/a/4859938
// replace the URL in manifest.json line 8 with a set of source URLs you want to redirect from
// replace the URL below with the destination URL you want to redirect to
chrome.runtime.sendMessage({redirect: "https://finance.yahoo.com/"});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment