// ==UserScript== // @name Pixiv Bookmark Count // @version 2.0.0 // @include http://www.pixiv.net/member_illust.php?* // @include http://www.pixiv.net/bookmark_new_illust.php* // @exclude http://www.pixiv.net/bookmark.php?id=* // @grant GM_xmlhttpRequest // @namespace https://greasyfork.org/users/7945 // @description イラストページ、作者作品一覧ページ、フォロー新着作品ページにて、各イラストのブックマーク数を表示します。 // @downloadURL none // ==/UserScript== var bmcontainer = document.getElementsByClassName('bookmark-container')[0]; var tarobj = document.getElementsByClassName('image-item'); var start = 0; function bm_xhr(illust_ID, tarobj) { GM_xmlhttpRequest({ url: "http://www.pixiv.net/bookmark_detail.php?" + illust_ID, method: "GET", onload: function(xhr) { var bmcount = xhr.responseText.match(/sprites-bookmark-badge.*?<\/a>/)[0].match(/\d+/)[0]; var icon = '' + bmcount + ''; if (bmcontainer) { if (!bmcontainer.textContent.match(/\d+/)) { var ax = document.createElement("a"); ax.innerHTML = icon; bmcontainer.insertBefore(ax, bmcontainer.firstChild); } } if (tarobj) { var ulx = document.createElement("ul"); ulx.innerHTML = icon; tarobj.appendChild(ulx); } } }); }; function func_bm() { for (var i = start; i < num; i++) { var illust_ID = tarobj[i].firstChild.href.match(/illust_id=\d+/); bm_xhr(illust_ID, tarobj[i]); } }; if (bmcontainer) { var illust_ID = location.href.match(/illust_id=\d+/); bm_xhr(illust_ID); } if (tarobj) { var num = tarobj.length; func_bm(); } window.addEventListener('GM_AutoPagerizeNextPageLoaded', function(event) { start = start + 20; num = tarobj.length; func_bm(); }, false);