Skip to content

Instantly share code, notes, and snippets.

@YungSang
Last active January 2, 2016 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save YungSang/8324805 to your computer and use it in GitHub Desktop.
Save YungSang/8324805 to your computer and use it in GitHub Desktop.
Taberareloo 用パッチ:SRWare Iron のリリースをチェックする
// ==Taberareloo==
// {
// "name" : "Check SRWare Iron Release"
// , "description" : "Check Release Announcement for SRWare Iron"
// , "include" : ["background"]
// , "version" : "2.0.0"
// , "downloadURL" : "https://gist.github.com/YungSang/8324805/raw/patch.check.iron.release.tbrl.js"
// }
// ==/Taberareloo==
(function() {
var CurrentIronVersion = window.navigator.appVersion.match(/Iron\/(.*?) /)[1];
if (!CurrentIronVersion) {
return;
}
var TITLE = 'Check SRWare Iron Release';
var URL = 'http://www.srware.net/forum/viewforum.php?f=18';
var OS = {
mac : "MacOS",
win : "Windows",
linux : "Linux"
};
function check(os) {
request(URL, {responseType : 'document'}).then(function (res) {
var doc = res.response;
var announcements = $X("//div[contains(@class,'announcement')]//li[contains(@class,'announce')]//a[@class='topictitle'][starts-with(text(),'New Iron-Version:')][contains(text(),'" + os + "')]", doc) || [];
announcements.forEach(function (announcement) {
var pagination = $X("./strong[@class='pagination']", announcement.parentNode)[0];
if (pagination) {
pagination.parentNode.removeChild(pagination);
}
var message = announcement.parentNode.innerText.replace(/\s+/g, ' ').trim();
var version = message.match(/New Iron-Version: (.*?) /)[1];
if (version !== CurrentIronVersion) {
TBRL.Notification.notify({
title : TITLE,
message : message,
onclick : function () {
window.open(announcement.href);
this.close();
}
});
} else {
TBRL.Notification.notify({
title : TITLE,
message : 'No New Version for ' + os + ' Released Yet',
timeout : 3,
onclick : function () {
this.close();
}
});
}
});
});
}
chrome.runtime.getPlatformInfo(function (info) {
var os = OS[info.os];
if (os) {
Menus._register({
type : 'separator',
contexts : ['all']
});
Menus._register({
title : TITLE,
contexts : ['all'],
onclick : function(info, tab) {
check(os);
}
});
Menus.create();
check(os);
}
});
localStorage.removeItem('iron_previous_announcements');
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment