B! No Display this User
by
maRk
2015-04-23 [2015/04/23 20:47:34]
はてなブックマークのユーザーページのユーザ名に関係する文字列等を非表示にする
/*
* @title B! No Display this User
* @description はてなブックマークのユーザーページのユーザ
* @include http://b.hatena.ne.jp/*
* @license MIT License
* @require
* @private
*/
(function () {
if (Hatena.Bookmark.author.hasOwnProperty('name')) {
var Arrays = Array.prototype.slice;
var u = Hatena.Bookmark.author.name;
var link = Hatena.Bookmark.author.link;
var sel1 = 'a[href*=\'' + link + '\']';
var sel2 = 'img[alt=\'' + u + '\']';
var nodisplay = function (s) {
Arrays.call(document.querySelectorAll(s)).forEach(function (e) {
e.style.display = 'none';
});
}
nodisplay(sel1);
nodisplay(sel2);
var b = document.getElementsByTagName('body') [0];
rmUserName(b);
}
return;
function rmUserName(e) {
var chNodes = e.childNodes;
for (var i = 0; i < chNodes.length; i++) {
var cn = chNodes[i];
if (cn.nodeType == 1) {
rmUserName(cn);
} else if (cn.nodeType == 3) {
cn.nodeValue = cn.nodeValue.replace(u, '');
} else if (cn.nodeType == 8){
// dummy
}
}
}
})();
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。