Skip to content

Instantly share code, notes, and snippets.

@nicolehe
Created April 5, 2017 03:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicolehe/baa46f29dc03ce8e2bab5a34343c7647 to your computer and use it in GitHub Desktop.
Save nicolehe/baa46f29dc03ce8e2bab5a34343c7647 to your computer and use it in GitHub Desktop.
tabomancy
chrome.browserAction.onClicked.addListener(function() {
console.log('clicked browser action');
chrome.tabs.query({
currentWindow: true
}, function(tabs) {
let message;
console.log(tabs.length);
if (tabs.length == 1) {
message = "Wow. Just wow. You are going to have an exceptional day, possibly one of the best in your entire life. Something truly extraordinary is bound to happen to you. It's going to be so amazing that it can really only going to be downhill from here! So enjoy it!";
} else if (tabs.length > 1 && tabs.length <= 4) {
message = "Things are going to be all right for you today. There may be something small that irritates you, but if you can let it go, it's going to be a perfectly fine day that you probably won't think about ever again.";
} else if (tabs.length > 4 && tabs.length <= 10) {
message = "Hmm, can't say you're going to be happy with what's in store for you today. Don't worry, it won't be the worst day in your life (that has yet to come), but something dark will loom over everything you do today. Watch out.";
} else if (tabs.length > 10) {
message = "Jesus Christ, oh my god. I'm so sorry. Today is going to be so tremendously awful that I don't know if you can ever recover from what's going to happen. I would recommend that you stay home but that actually will not make it better. It might make it worse.";
}
alert(message);
});
});
{
"name": "Daily Fortune",
"manifest_version": 2,
"short_name": "Daily Fortune",
"version": "0.1",
"browser_action": {
"default_title": "Daily Fortune"
},
"permissions": [
"tabs"
],
"background": {
"scripts": ["background.js"]
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment