Skip to content

Instantly share code, notes, and snippets.

@nomeaning777
Created September 30, 2012 14:51
Show Gist options
  • Save nomeaning777/3806995 to your computer and use it in GitHub Desktop.
Save nomeaning777/3806995 to your computer and use it in GitHub Desktop.
UserScript that works with Opera and Firefox
// ==UserScript==
// @name Virtual Arena Link Change
// @namespace http://twitter.com/k_operafan
// @version 1.0.0
// @description Virtual Areena(AOJ)のLiveArchiveのリンクをpdfからhtmlに書きかえる。
// @include http://rhodon.u-aizu.ac.jp:8080/arena/*
// ==/UserScript==
(function(){
function func(){
var la = 'http://livearchive.onlinejudge.org/external/';
var obj = jQuery(this);
var link = obj.attr("href");
if(link.substr(0, la.length) == la){
var target = link.substr(0, link.length - 3) + 'html';
var id = link.substr(la.length);
id = id.replace('.pdf', '');
id = id.substr(id.indexOf('/') + 1);
// 存在確認
$.getJSON("http://test.k8n.biz/tools/la_check.cgi?id=" + id + "&callback=?",
function(data){
if(data.code == "200"){
obj.attr("href", target);
}
}
);
}
}
setTimeout(function(){
$('a').each(func);
},500);
})();
@nomeaning777
Copy link
Author

VirtualArenaのデザイン変更に対応

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment