NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Pixiv - Show bookmark count // @name:ja Pixiv - ブックマーク数を表示する // @name:zh-cn Pixiv - 显示作品收藏数 // @name:zh-tw Pixiv - 顯示作品書簽數 // @namespace pixiv-bookmark-count // @description Show bookmark count // @description:ja イラストのブックマーク数を表示します // @description:zh-cn 显示作品收藏数 // @description:zh-tw 顯示作品書簽數 // @run-at document-end // @version 0.1 // @author raingart // @license Apache-2.0 // @include https://www.pixiv.net/* // @exclude https://www.pixiv.net/*#ppixiv // @grant none // ==/UserScript== /*jshint esversion: 6 */ (function() { const class_name = 'sc-'+ Math.random().toString(36).slice(2, 7).slice(-5); selector = [ {url: /pixiv.net\/(cate_r18|manga|en\/$|$)/, sel: 'ul div>div>div:nth-of-type(1)>a'}, {url: /pixiv.net\/(en\/)?artworks/, sel: 'ul div>div>div>a'}, {url: 'pixiv.net/bookmark_new_illust', sel: 'ul div>div>div>a'}, {url: 'pixiv.net/contest', sel: '.thumbnail-container>a'}, {url: 'pixiv.net/discovery', sel: 'ul div>div>div:nth-of-type(1)>a'}, {url: 'pixiv.net/new_illust', sel: 'ul div>div:nth-of-type(1)>div>a'}, {url: 'pixiv.net/ranking', sel: '.ranking-image-item>a'}, {url: /pixiv.net\/request/, sel: 'ul div>div:nth-of-type(1)>a'}, {url: /pixiv.net\/(en\/)?tags/, sel: 'ul div>div>div>a'}, {url: /pixiv.net\/(en\/)?users/, sel: 'ul div>div:nth-of-type(1)>div:nth-of-type(1)>a, ul div>div div>div>a:nth-child(1)'}, {url: /pixiv.net\/user\/\d+\/series\/\d+/, sel: 'ul div>div>div>a'} ] .map(i => {i.sel += `[href*="/artworks/"]:not(.${class_name})`; return i}); document.head.insertAdjacentHTML('beforeend', `<style> .bmc { position: absolute; left: 4px; top: 4px; text-align: center; color: #005a96; background-color: #c8e6fa; border-radius: 4px; padding: 2px 4px; font-family: Verdana; font-size: 10pt; font-weight: bold; } </style>`); const App ={ //prevURL: document.URL, // onUrlChange isURLChanged() { return (this.prevURL == document.URL) ? false : this.prevURL = document.URL; }, init() { const match = selector.find(s => document.URL.match(s.url)); match && document.body.querySelectorAll(match.sel) ?.forEach(async a => { a.classList.add(class_name); const illust_id = a.href.match(/(?<=\/artworks\/)\d+/)[0]; if (illust_bc = (await (await fetch('https://www.pixiv.net/ajax/illust/' + illust_id, {credentials: 'omit'})).json())?.body?.bookmarkCount) { a.parentNode.insertAdjacentHTML('afterend', `<span class="bmc">${illust_bc}</span>`); } }); }, }; window.addEventListener('load', App.init); window.addEventListener('transitionend', () => App.isURLChanged() && App.init()); })();