Last active
February 27, 2018 12:07
-
-
Save masaakif/484213 to your computer and use it in GitHub Desktop.
MediaMarker Improvements
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name MediaMarker Improvements | |
| // @namespace http://gist.github.com/484213 | |
| // @include http://mediamarker.net/* | |
| // ==/UserScript== | |
| // | |
| if (0 < location.href.indexOf("reg?cat=")) clickRegisterBtn(); | |
| libsearch(); | |
| removeIcons(); | |
| changeImageForIcons(); | |
| function libsearch() { | |
| var links = document.evaluate("//div[@class='med_title']", document, | |
| null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
| for (var i = 0; i < links.snapshotLength ; i = i + 1) { | |
| var ln = links.snapshotItem(i); | |
| var idl = ln.getElementsByTagName("span")[0]; | |
| var id = idl.getAttribute("id").replace('marker',''); | |
| var al = ln.getElementsByTagName("a")[0]; | |
| var asin = al.getAttribute('href').replace(/.*\/dp\/([\dA-Z]{10}).*/, '$1'); | |
| al.setAttribute('href', 'http://mediamarker.net/u/masaakif/edit' + id); | |
| idl.appendChild(createChuoWardLink(asin)); | |
| idl.appendChild(createCalilLink(asin)); | |
| } | |
| } | |
| function removeIcons() { | |
| removeImage("icon_introlink.gif"); | |
| removeImage("icon_page.gif"); | |
| } | |
| function changeImageForIcons() { | |
| changeImage("icon_edit.gif", 36, "http://clients.donschnitzius.com/sungard/images/btn-edit.png"); | |
| changeImage("icon_delete.gif", 60, "http://clients.donschnitzius.com/sungard/images/btn-delete.png"); | |
| } | |
| function removeImage(str) { | |
| var links = document.evaluate("//img", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
| for (var i = 0; i < links.snapshotLength; i = i + 1) { | |
| var im = links.snapshotItem(i); | |
| if (0 <= im.src.indexOf(str)) { | |
| var ln = im.parentNode; | |
| ln.removeChild(im); | |
| } | |
| } | |
| } | |
| function changeImage(str, width, url) { | |
| var links = document.evaluate("//img", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); | |
| for (var i = 0; i < links.snapshotLength ; i = i + 1) { | |
| var im = links.snapshotItem(i); | |
| if (im.src.indexOf(str) < 0) { | |
| continue; | |
| } | |
| im.width= width; | |
| im.src = url; | |
| } | |
| } | |
| function alertElem(elem) { | |
| var str = ""; | |
| for (var i = 0; i < elem.length; i = i + 1) { | |
| str = str + elem.item[i] | |
| } | |
| } | |
| function createCalilLink(asin){ | |
| var link = document.createElement('a'); | |
| link.setAttribute('href', 'http://calil.jp/book/' + asin); | |
| link.setAttribute('target', '_blank'); | |
| link.innerHTML = '<span style=\"font-size:10px; background-color:#ffffcc;\">»Open Calil<br></span>'; | |
| return link; | |
| } | |
| function createChuoWardLink(asin) { | |
| var f = document.createElement('form'); | |
| f.setAttribute('method', 'POST'); | |
| f.setAttribute('action', 'http://www.library.city.chuo.tokyo.jp/clis/search'); | |
| f.setAttribute('id', 'frmGMChuoLib' + asin); | |
| f.setAttribute('onsubmit', 'return false;'); | |
| f.setAttribute('target', '_blank'); | |
| var fi = document.createElement('input'); | |
| fi.setAttribute('type', 'hidden'); | |
| fi.setAttribute('name', 'ISBN'); | |
| fi.setAttribute('value', asin); | |
| f.appendChild(fi); | |
| var spl_link = document.createElement('a'); | |
| spl_link.setAttribute('href', "javascript:document.forms['frmGMChuoLib" + asin + "'].submit();"); | |
| spl_link.setAttribute('title', 'To Chuo Ward City Library'); | |
| spl_link.innerHTML = '<span style=\"font-size:10px; background-color:#ffffcc;\">»中央区立図書館検索</span>'; | |
| f.appendChild(spl_link); | |
| return f; | |
| } | |
| function clickRegisterBtn() | |
| { | |
| var btn = document.evaluate("//div[@class='reg_btn']/input[@name='reg3']", document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue; | |
| btn.click(); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment