Sleipnirのお気に入りの検索の結果のHTML構造を書き直すスクリプト書いた
い…いそがしい
ここ数日はTwitterすら碌に見れてないです。
まぁ年度末ですからね。
私のところの峠はそろそろ過ぎそうなんでぼちぼち復活できるはず。
Sleipnirファミリーの多言語化
デベロッパーズブログの英語版でSleipnirファミリーの翻訳の手助けしてくれる人を募集されています。
Translators wanted for Windows, Mac and now the Mobile versions of Sleipnir web browser
日本人は複数言語できる人が少ないとはいえ日本語版ブログでも募集すればいいのにね。
そんなわけで外国語ができる人は協力してあげてくださいw
とはいえ各プラットフォームのSleipnirによって翻訳状況の進捗は違うようなので、各プラットフォーム・各言語における状況はブログの方で確認してね。
なお、私はユニリンガル(?)なので協力できましぇんw
今日は前哨戦
先日スクリプトのネタが無いみたいなこと書いたけど、よく考えたらアイディアをメモってストックしておいたのだった。
要するに技量の問題とかやる気の問題とかで後回しになっていたやつですね。
その中に「お気に入りを複数キーワードで検索できるようにする」というのがあったので、今回はこれを作ることにした。
だが、BookmarkSearchによって出力されるHTMLが非常にアレであったので、まずはそれを再構築するスクリプトを書いた。
今日はそこまででやる気失せて中途半端なんだけど、曝してみることにした。
まだ、無駄な記述とかあるんだけど途中なんでw
BookmarkSearchReconstructior.user.js
// ==UserScript== // @name BookmarkSearchReconstructior // @include file:///?:/*/caches/bookmark_search/SearchBookmark-?*.html // @type SleipnirScript // ==/UserScript== (function(){ var aar = [], tar = [], sar = []; // 各お気に入りのURIとそのテキストノードを保存 var atag = _document.body.getElementsByTagName("a"); for(var i = 0; i < atag.length; i++) { if(atag[i].style.lineHeight == "140%" && atag[i].target == "_top") { aar.push(atag[i].href); tar.push(atag[i].innerText); } } // 各お気に入りの階層を保存 var spntag = _document.body.getElementsByTagName("span"); for(var i = 0; i < spntag.length; i++) { if(spntag[i].style.color === "gray") { sar.push(spntag[i].innerText); } } // オリジナルの要素を全削除 while(document.body.lastChild){ document.body.removeChild(document.body.lastChild); } // ロゴ var logo = document.createElement("img"); logo.src = "http://www.fenrir.co.jp/local/sleipnir_bookmark_search.gif"; document.body.appendChild(logo); // 上側の水平線 var top = document.createElement("div"); top.style.borderTop = "1px solid #3366cc"; top.style.borderBottom = "1px solid #3366cc"; top.style.background = "#e5ecf9"; top.style.padding = "0.1em"; top.style.fontWeight = "bold"; top.style.fontSize = "medium"; top.innerText = "お気に入り"; document.body.appendChild(top); // 検索結果の件数など var word = document.createElement("div"); word.style.float = "right"; word.style.margin = "-1.0em 0.1em 0.1em auto"; top.appendChild(word); var keyWd = document.createElement("span"); keyWd.id = "keyWd"; keyWd.style.fontSize = "small"; keyWd.innerText = document.title.split(" ")[0]; word.appendChild(keyWd); var cnt = document.createElement("span"); cnt.id = "cnt"; cnt.style.fontWeight = "normal"; cnt.style.fontSize = "small"; cnt.innerText = " の検索結果 (" + aar.length + "件)"; word.appendChild(cnt); // 各お気に入りの再作成 for(var i = 0; i < aar.length; i++) { var main = document.createElement("div"); main.id = "div" + parseInt(i, 16); main.style.margin = "0.5em 0"; document.body.appendChild(main); // お気に入りへのリンク var ldiv = document.createElement("div"); main.appendChild(ldiv); var lnk = document.createElement("a"); lnk.target = "_top"; lnk.style.lineHeight = "140%"; lnk.style.fontSize = "medium"; lnk.href = aar[i]; lnk.innerText = tar[i]; ldiv.appendChild(lnk); // お気に入りの階層 var bdiv = document.createElement("div"); main.appendChild(bdiv); var brd = document.createElement("span"); brd.style.lineHeight = "120%"; brd.style.fontSize = "small"; brd.style.color = "gray"; brd.style.display = "block"; brd.innerText = sar[i]; bdiv.appendChild(brd); // お気に入りのURI var pth = document.createElement("span"); pth.style.lineHeight = "120%"; pth.style.fontSize = "small"; pth.style.color = "#008000"; pth.innerText = aar[i] + " - "; main.appendChild(pth); // お気に入りのキャッシュリンク var cch = document.createElement("a"); cch.target = "_top"; cch.style.marginTop = "0.75em"; cch.style.marginBottom = "0.75em"; cch.style.fontSize = "small"; cch.style.color = "#7f7fcf"; cch.href = "http://www.google.com/search?q=cache:" + aar[i]; cch.innerText = "キャッシュ"; main.appendChild(cch); // ハイフン var spc = document.createElement("span"); spc.innerText = " - "; main.appendChild(spc); // お気に入りのアーカイブリンク var arc = document.createElement("a"); arc.target = "_top"; arc.style.marginTop = "0.75em"; arc.style.marginBottom = "0.75em"; arc.style.fontSize = "small"; arc.style.color = "#7f7fcf"; arc.href = "http://web.archive.org/web/*/" + aar[i]; arc.innerText = "アーカイブ"; main.appendChild(arc); } // 下側の水平線 var btm = document.createElement("div"); btm.style.borderTop = "1px solid #3366cc"; btm.style.borderBottom = "1px solid #3366cc"; btm.style.background = "#e5ecf9"; btm.style.padding = "0.1em"; btm.style.fontWeight = "bold"; btm.style.fontSize = "medium"; btm.innerText = " "; document.body.appendChild(btm); // コピーライト var cpy = document.createElement("div"); cpy.style.margin = "1.0em auto"; cpy.style.textAlign = "center"; cpy.innerHTML = "©2006-" + new Date().getFullYear() + " Fenrir Inc."; document.body.appendChild(cpy); })();
これからの予定
- 複数キーワードでの検索実装
- cocoaさんのBookmarkSearchToEditorの機能を移植