Skip to content

Instantly share code, notes, and snippets.

@hekt
Created July 25, 2013 12:44
Show Gist options
  • Save hekt/6079253 to your computer and use it in GitHub Desktop.
Save hekt/6079253 to your computer and use it in GitHub Desktop.
skip hatebu
(function() {
var urls = ['http://b.hatena.ne.jp/entry/',
'http://zenback.itmedia.co.jp/contents/',
'http://ceron.jp/url/'];
chrome.tabs.onUpdated.addListener(function(tabid, inf, tab) {
for (var i = 0; i < urls.length; i++) {
if (inf.url.indexOf(urls[i]) === 0) {
var newUrl = inf.url.replace(/^(https?:\/\/).*?\/.*?\/(.*)$/, '$1$2');
chrome.tabs.update(tabid, {"url": newUrl});
break;
}
}
});
})();
{
"name": "skip hatebu",
"version": "1.0",
"manifest_version": 2,
"permissions": ["tabs", "http://*/*"],
"background": {
"scripts": ["background.js"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment