Greasy Fork is available in English.
イラストページ、作者作品一覧ページ、フォロー新着作品ページにて、各イラストのブックマーク数を表示します。
当前为
// ==UserScript==
// @name Pixiv Bookmark Count
// @version 1.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
// @description イラストページ、作者作品一覧ページ、フォロー新着作品ページにて、各イラストのブックマーク数を表示します。
// @namespace http://greasyfork.icu/users/7945
// ==/UserScript==
var sessionID = document.cookie.match(/PHPSESSID=[^;]+/);
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://spapi.pixiv.net/iphone/illust.php?" + sessionID + "&" + illust_ID,
method: "GET",
onload: function(xhr) {
var bmcount = xhr.responseText.split("\"").reverse()[9];
if (bmcount > 0) {
var icon = '<a class="bookmark-count _ui-tooltip" href="/bookmark_detail.php?' + illust_ID + '"><i class="_icon sprites-bookmark-badge"></i>' + bmcount + '</a>';
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);