Expand Hatena::Star
by
noromanba
2014-12-11 [2014/12/11 03:55:50]
expand Hatena::Star handle colored stars
@@ -2,13 +2,19 @@
* @title Expand Hatena::Star
* @description Expand Hateha::Star handle colored stars
* @include http://*
+ * @include https://*
* @license MIT License http://nrm.mit-license.org/2012
- * @require
+ * @javascript_url
*/
+// c.f.
+// http://ptech.g.hatena.ne.jp/noromanba/20120423/1335205764
+// e.g.
+// http://d.hatena.ne.jp/amachang/archive
+
// http://os0x.g.hatena.ne.jp/os0x/20080502/1209724672
//console.time('*runtime');
-(function(Hatena) {
+(function (Hatena) {
if (typeof Hatena === 'undefined') return;
Hatena.Star.EntryLoader.entries.forEach(function (entry) {
@@ -17,7 +23,7 @@
entry.stars.some(function (star) {
if (star && star.count && star.showInnerStars) {
star.showInnerStars();
- return true; // rustic
+ return true;
}
});
}
@@ -73,4 +79,4 @@
> *runtime: 14ms -> *runtime: 1ms
Expand event sequence probably async. It's looks like so fast but actual finish time is too long :-P
-*/
+*/
/*
* @title Expand Hatena::Star
* @description Expand Hateha::Star handle colored stars
* @include http://*
* @include https://*
* @license MIT License http://nrm.mit-license.org/2012
* @javascript_url
*/
// c.f.
// http://ptech.g.hatena.ne.jp/noromanba/20120423/1335205764
// e.g.
// http://d.hatena.ne.jp/amachang/archive
// http://os0x.g.hatena.ne.jp/os0x/20080502/1209724672
//console.time('*runtime');
(function (Hatena) {
if (typeof Hatena === 'undefined') return;
Hatena.Star.EntryLoader.entries.forEach(function (entry) {
var expander = entry.star_container.querySelector('span.hatena-star-inner-count');
if (expander && expander.textContent) {
entry.stars.some(function (star) {
if (star && star.count && star.showInnerStars) {
star.showInnerStars();
return true;
}
});
}
});
})(window.Hatena);
//console.timeEnd('*runtime');
/*
# About
Witten in [GitHub Flavored Markdown] (http://github.github.com/github-flavored-markdown/)
## Performance on http://d.hatena.ne.jp/amachang/
1st -> 2nd execute times on acutual environment.
+ debug code included
+ disable cache
### nonDOM
> *runtime: 47ms -> *runtime: 57ms
It's too slow when 2nd execute or after.
### useDOM
DOM select part like this.
Hatena.Star.EntryLoader.entries[0].star_container.querySelector('SELECTOR');
#### selectors
+ .hatena-star-star-container > .hatena-star-inner-count
> *runtime: 36ms -> *runtime: 2ms
+ span.hatena-star-star-container > span.hatena-star-inner-count
> *runtime: 51ms -> *runtime: 3ms
+ span.hatena-star-inner-count
> *runtime: 42ms -> *runtime: 2ms
+ .hatena-star-inner-count
> *runtime: 39ms -> *runtime: 3ms
#### Disable heavy Greasemonkey Script (star icon change to profile)
+ span.hatena-star-inner-count
> *runtime: 4ms -> *runtime: 0ms
## Performance on http://d.hatena.ne.jp/amachang/archive
1st -> 2nd execute times.
+ enable debug code but console.time() and console.timeEnd() only
+ disable cache
#### Disable heavy Greasemonkey Script (star icon change to profile)
+ span.hatena-star-inner-count
> *runtime: 14ms -> *runtime: 1ms
Expand event sequence probably async. It's looks like so fast but actual finish time is too long :-P
*/
- Permalink
- このページへの個別リンクです。
- RAW
- 書かれたコードへの直接のリンクです。
- Packed
- 文字列が圧縮された書かれたコードへのリンクです。
- Userscript
- Greasemonkey 等で利用する場合の .user.js へのリンクです。
- Loader
- @require やソースコードが長い場合に多段ロードする Loader コミのコードへのリンクです。
- Metadata
- コード中にコメントで @xxx と書かれたメタデータの JSON です。