Last active
December 12, 2015 09:49
-
-
Save gh640/4754477 to your computer and use it in GitHub Desktop.
神戸市図書館蔵書検索ブックマークレット。
This file contains 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
javascript:(function(){ | |
/* 神戸市図書館蔵書検索ブックマークレット */ | |
/* 選択された文字列を取得する なければダイアログで取得する */ | |
var kwd = ""+(window.getSelection?window.getSelection():document.getSelection()); | |
if(!kwd){ | |
kwd = prompt("Kobe lib search... ",""); | |
} | |
/* POST送信用のフォームを作成する */ | |
var act = document.createElement('form'); | |
act.id = 'kobe_lib'; | |
act.action = 'https://www.lib.city.kobe.jp/opac/opacs/find_books'; | |
act.method = 'post'; | |
/* フォーム内のインプット要素を作成する */ | |
function createInput(name, value){ | |
var e = document.createElement('input'); | |
e.name = name; | |
e.value = value; | |
e.type = 'hidden'; | |
return e; | |
} | |
var e1 = createInput('keywords', kwd); | |
var e2 = createInput('keyword-andor', 'and'); | |
var e3 = createInput('btype', 'B'); | |
var e4 = createInput('lang', 'all'); | |
var e5 = createInput('AGE', 'b'); | |
var e6 = createInput('dispcnt', '50'); | |
var e7 = createInput('searchmode', 'simp'); | |
var e8 = createInput('id', '1'); | |
/* 作成した要素群をフォームに、フォームをドキュメントに追加する */ | |
function appendChildren(p, c){ | |
for(var i = 0;i<c.length;i++){ | |
p.appendChild(c[i]); | |
} | |
} | |
appendChildren(act, [e1, e2, e3, e4, e5, e6, e7, e8]); | |
document.body.appendChild(act); | |
/* 送信 */ | |
document.getElementById('kobe_lib').submit(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment