Created
July 26, 2008 12:02
-
-
Save monmon/2638 to your computer and use it in GitHub Desktop.
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 hatena_bookmark_cmptag | |
| // @namespace http://github.com/monmon | |
| // @description 「おすすめタグ」と「キーワード」に自分のタグがあれば目立たせる | |
| // @include http://b.hatena.ne.jp/add* | |
| // @include http://b.hatena.ne.jp/*/edit* | |
| // ==/UserScript== | |
| (function(){ | |
| // グローバル変数にアクセスするためにhead読んでevalしてる | |
| // たまたまvarの宣言してあるのが7番目ってだけ | |
| // もっとよい方法ないかな | |
| var scriptTag = document.getElementsByTagName('head')[0].getElementsByTagName('script')[6]; | |
| if (scriptTag) { // 既にはてブに追加してある場合は<script>がないので確認 | |
| eval( scriptTag.innerHTML ); | |
| } | |
| else { // 登録してある場合は抜ける | |
| return; | |
| } | |
| var onload = function(e){ | |
| function cmpTag(others,mine,id) { | |
| var mineLength = mine.length; | |
| for (var i = 0,l = others.length; i < l; i++) { // 他ユーザタグを全部なめる | |
| for (var j = 0; j < mineLength; j++) { // 自分のタグを全部なめる | |
| if (others[i] == mine[j]) { // 文字の比較 | |
| document.getElementById(id + i).style.border | |
| = 'solid 5px #eee'; | |
| break; // 一致したらその後の自タグをなめる必要ないので抜ける | |
| } | |
| } | |
| } | |
| } | |
| cmpTag(otherTags,tags,"otherTag"); | |
| cmpTag(keywords,tags,"keyword"); | |
| // デタッチ | |
| window.removeEventListener("load", onload, false); | |
| } | |
| // アタッチ | |
| window.addEventListener("load", onload, false); | |
| })() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment