I wrote a Chrome extension tonight that redirects me to my to-do list if I try to go to Reddit. Or, at least, it redirects me 95% of the time. It was basically four lines of code:
chrome.tabs.onUpdated.addListener(function(tabID, changeInfo, tab){
if (tab.url && (tab.url.search("www.reddit.com") != -1)){
if (Math.random() < 0.95){
chrome.tabs.update(tabID,{url: "https://keep.google.com/#home"});
}
}
});
So far, it's working. I can't believe it took me as long as it did to get around to writing it.
Probably because I was on Reddit all the time.
[Well, not really, but the joke isn't effective otherwise.]
Peace out.
chrome.tabs.onUpdated.addListener(function(tabID, changeInfo, tab){
if (tab.url && (tab.url.search("www.reddit.com") != -1)){
if (Math.random() < 0.95){
chrome.tabs.update(tabID,{url: "https://keep.google.com/#home"});
}
}
});
So far, it's working. I can't believe it took me as long as it did to get around to writing it.
Probably because I was on Reddit all the time.
[Well, not really, but the joke isn't effective otherwise.]
Peace out.
No comments:
Post a Comment