Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save syoichi/819607 to your computer and use it in GitHub Desktop.
Save syoichi/819607 to your computer and use it in GitHub Desktop.
仕様変更に対応した。ツイートが多い場合は、誤解防止の為、「残りを読む」でツイートを全て読み込まないと表示されないようにした。
// ==UserScript==
// @id Togetter List Owner Post Counter
// @name Togetter List Owner Post Counter
// @namespace http://d.hatena.ne.jp/Pasta-K
// @author Pasta-K
// @version 0.0.2.20110805190818
// @description http://d.hatena.ne.jp/Pasta-K/20100321/1269164746
// @include http://togetter.com/li/*
// @run-at document-end
// @priority 0
// @compatibility Firefox 5.0(Scriptish 0.1.3), Chrome 13.0.782.107, Safari 5.1(NinjaKit 0.8), Opera 11.50 on Windows 7 Enterprise 32bit
// @charset UTF-8
// @note ツイートが多い場合は、誤解防止の為、「残りを読む」でツイートを全て読み込まないと表示されないようにした
// ==/UserScript==
/* jslint browser: true, maxerr: 50, maxlen: 80, indent: 4 */
// Edition 2011-08-03
(function (doc) {
'use strict';
var tweetBox = doc.querySelector('.tweet_box'),
tweetCounter;
tweetCounter = function tweetCounter(event) {
var author, tweetList, tweetListLen, tweetLen, count;
if (event) {
if (event.target.tagName === 'UL') {
tweetBox.removeEventListener(
'DOMNodeInserted',
tweetCounter,
false
);
} else {
return;
}
}
author = doc.querySelector('.profile_image > img').alt;
tweetList = tweetBox.getElementsByClassName('twttrimg');
tweetListLen = tweetLen = tweetList.length;
count = 0;
while (tweetListLen) {
if (author === tweetList[tweetListLen -= 1].alt) {
count += 1;
}
}
if (count) {
doc.querySelector('.icon_view').nextSibling.textContent =
' ' + (count / tweetLen * 100).toFixed(1) +
'%(' + count + '/' + tweetLen + ')';
}
};
if (doc.querySelector('[id^="more_tweet_box"]')) {
tweetBox.addEventListener('DOMNodeInserted', tweetCounter, false);
} else {
tweetCounter();
}
}(document));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment