// ==UserScript== // @name Pixiv Bookmark Count // @version 3.0.0 // @include https://www.pixiv.net/member_illust.php?* // @include https://www.pixiv.net/bookmark_new_illust.php* // @grant GM_xmlhttpRequest // @namespace https://greasyfork.org/users/7945 // @description イラストページ、作者作品一覧ページ、フォロー新着作品ページにて、各イラストのブックマーク数を表示します。『Endless Pixiv Pages』や『AutoPagerize』で継ぎ足されたページにも対応します。 // @downloadURL none // ==/UserScript== function bm_xhr(illust_ID, tarobj) { GM_xmlhttpRequest({ url: "https://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); } } else { var ulx = document.createElement("ul"); ulx.innerHTML = icon; tarobj.appendChild(ulx); } } }); } var bmcontainer = document.getElementsByClassName('bookmark-container')[0]; if (bmcontainer) { var illust_ID = location.href.match(/illust_id=\d+/); bm_xhr(illust_ID); } else { document.body.addEventListener('DOMNodeInserted', function() { if (location.href.match('bookmark_new_illust.php')) var tarobj = document.getElementsByClassName('gmzooM4'); else var tarobj = document.getElementsByClassName('image-item'); if (tarobj[0]) { (function() { for (var i = 0, l = tarobj.length; i < l; i++) { if (tarobj[i].classList.contains('dummy') == false) { tarobj[i].classList.add('dummy'); var illust_ID = tarobj[i].getElementsByTagName('a')[0].href.match(/illust_id=\d+/); bm_xhr(illust_ID, tarobj[i]); } } })(tarobj); } }, false); }