Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
97 lines (90 sloc) 3.01 KB
<html>
<head>
<script>
// ---- CHECK UPDATE ----//
var major = 2;
var minor = 1;
if (localStorage["major"] == undefined) {
localStorage["major"] = 0;
}
if (localStorage["major"] < major) {
chrome.tabs.create({url:chrome.extension.getURL("options.html#update")});
localStorage["uncheckedUpdate"] = true;
localStorage["major"] = major;
}
if (localStorage["minor"] == undefined) {
localStorage["minor"] = 0;
}
if (localStorage["minor"] < minor) {
localStorage["uncheckedUpdate"] = true;
localStorage["minor"] = minor;
}
// ---- END CHECK UPDATE ----//
//---- TALK TO ICON ----//
chrome.tabs.onUpdated.addListener(checkForGcal);
function checkForGcal(tabId, changeInfo, tab) {
if (localStorage["uncheckedUpdate"] == "true") {
chrome.pageAction.setIcon({tabId: tab.id, path: "img/icons/icon19_update.png"});
chrome.pageAction.setTitle({tabId: tab.id, title:"Minimalist for Google Reader has been updated! Click to dismiss."});
} else {
chrome.pageAction.setIcon({tabId: tab.id, path: "img/icons/icon19.png"});
chrome.pageAction.setTitle({tabId: tab.id, title: "Minimalist for Google Reader Options"});
localStorage["uncheckedUpdate"] = false;
}
var o = JSON.parse(localStorage["options"]);
if (tab.url.indexOf('google.com/reader') > -1 && !o.mricon) {
chrome.pageAction.show(tabId);
}
};
//---- END TALK TO ICON ----//
//---- TALK TO SCRIPTS ----//
var joy = true; // whether or not Minimalist for Google Reader is activated [via icon]
chrome.extension.onRequest.addListener(function (request, sender, sendResponse) {
if (request.elements == "o" && joy) {
sendResponse({
"o": JSON.parse(localStorage["options"])
});
}
if (request.elements == "e") {
sendResponse({
"e": localStorage["easterEgg"]
});
}
if (request.action == "reload") reloadTab();
if (request.action == "toggle") joy ? joy = false : joy = true;
if (request.url){
chrome.tabs.create({"url":request.url, "selected":false});
}
});
//---- END TALK TO SCRIPTS ----//
//---- HELPER METHODS ----//
function reloadTab() {
chrome.windows.getCurrent(function(win) {
var cwin = win.id;
chrome.tabs.getAllInWindow(cwin, function(tabs) {
for (var i = 0; i < tabs.length; i++) {
var t = tabs[i].url;
if (t.match('google.com/reader')) {
var tab = tabs[i];
chrome.tabs.update(tab.id, {url: tab.url, selected: tab.selected}, null);
}
}
});
});
}
//---- END HELPER METHODS ----//
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-21841375-1']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</head>
<body>
</body>
</html>