Skip to content

Instantly share code, notes, and snippets.

@monmon
Created July 24, 2008 05:00
Show Gist options
  • Select an option

  • Save monmon/2052 to your computer and use it in GitHub Desktop.

Select an option

Save monmon/2052 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name LDR_hide_mark_read
// @namespace http://github.com/monmon
// @description hide mark read.
// @include http://reader.livedoor.com/reader/
// ==/UserScript==
(function () {
var count = 0;
document.getElementById('right_body').addEventListener('DOMNodeInserted', handler, false);
document.body.addEventListener('click', function(e) {
if (! e.target.className.match(/\s?treeitem\s?/)) return; // RSSをクリックしたとき以外は抜ける
count = ( e.target.innerHTML.match(/\(([0-9]*)\)/) ) ? RegExp.$1 : 1;
// GM_log('count: ' + count);
}, false);
function handler (e) {
// GM_log('in');
$x('id("right_body")//div[@class="item_info"]/a').forEach(function(a, num, array){
if (count > array.length) return;
/*
if ($x('id("right_body")//div[@class="item_header"]//h2/a')[num] != null)
GM_log(
num + ' : '
+ (document.defaultView.getComputedStyle(a, null).getPropertyValue("color") == 'rgb(85, 26, 139)') + ':'
+ document.defaultView.getComputedStyle(a, null).getPropertyValue("color") + ':'
+ $x('id("right_body")//div[@class="item_header"]//h2/a')[num].innerHTML
);
*/
if (document.defaultView.getComputedStyle(a, null).getPropertyValue("color") == 'rgb(85, 26, 139)') {
num++;
var elem =
(unsafeWindow.document.getElementById('item_count_' + num) != null) ? unsafeWindow.document.getElementById('item_count_' + num).parentNode :
null;
if (elem != null) {
// GM_log('remove?' + ': ' + elem.id);
// display:noneだとj,kのキーイベントでの移動がおかしくなるのでremoveChild
elem.parentNode.removeChild(elem);
// GM_log('remove: OK');
}
}
});
}
// システム系の関数(コピペ)
/**
* $x()
* http://lowreal.net/2006/shibuya-js-1-lt.html
* http://lowreal.net/logs/2006/03/16/1
* // main という id をもつ要素
* $X("id('section')");
*
* // section という class をもつ div 列挙
* $X("//div[@class='section']");
*
* // 最初の h1 要素
* $X("//h1[0]");
*
* // 最後の p 要素
* $X("//p[last()]");
*
* // address 要素以下で、
* // mailto スキームから始まる a 要素
* $X("//address//a[starts-with(@href, 'mailto:')]");
*/
function $x(exp, context) {
if (!context) context = document;
var resolver = function (prefix) {
var o = document.createNSResolver(context)(prefix);
return o ? o : (document.contentType == "text/html") ? "" : "http://www.w3.org/1999/xhtml";
}
var exp = document.createExpression(exp, resolver);
var result = exp.evaluate(context, XPathResult.ANY_TYPE, null);
switch (result.resultType) {
case XPathResult.STRING_TYPE : return result.stringValue;
case XPathResult.NUMBER_TYPE : return result.numberValue;
case XPathResult.BOOLEAN_TYPE: return result.booleanValue;
case XPathResult.UNORDERED_NODE_ITERATOR_TYPE: {
result = exp.evaluate(context, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
var ret = [];
for (var i = 0, len = result.snapshotLength; i < len ; i++) {
ret.push(result.snapshotItem(i));
}
return ret;
}
}
return null;
}
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment