// ==UserScript== // @include http://toolserver.org/~nikola/svgtranslate.php?* // ==/UserScript== function showThumbnail(resp) { if(!resp || !resp.query || !resp.query.pages) { return; } resp = resp.query.pages; for(var e in resp) { resp = resp[e]; break; } if(!resp || !resp.imageinfo || !resp.imageinfo[0]) { return; } resp = resp.imageinfo[0]; if(!resp.thumburl || !resp.thumbwidth || !resp.thumbheight || !resp.descriptionurl) { return; } var a = document.createElement("a"); a.setAttribute("href", resp.descriptionurl); var img = a.appendChild(document.createElement("img")); img.setAttribute("src", resp.thumburl); img.setAttribute("width", resp.thumbwidth); img.setAttribute("height", resp.thumbheight); img.style.border = "1px solid #aaa"; img.style.cssFloat = "right"; document.body.insertBefore(a, document.forms[0]); } (function() { var path = /^(?:&|\?)svg=([^&]+)/.exec(window.location.search); if(!path) { return; } path = /^(?:https?:\/\/)(?:[^\/]+)\/([^\/]+)\/([^\/]+)\/.+?\/([^\/]+)$/.exec( decodeURIComponent(path[1])); if(!path) { return; } var parameters = [ "action=query", "prop=imageinfo", "iiprop=url", "iiurlwidth=600", "iiurlheight=600", "format=json", "callback=showThumbnail", "titles=" + "File:" + encodeURIComponent(path[3])]; var api = encodeURI("http://" + path[2] + "." + path[1] + ".org/w/api.php"); var script = document.createElement("script"); script.setAttribute("type", "text/javascript"); script.setAttribute("encoding", "UTF-8"); script.setAttribute("defer", "defer"); script.setAttribute("src", api + "?" + parameters.join("&")); document.getElementsByTagName("head")[0].appendChild(script); })();