Greasy Fork

Greasy Fork is available in English.

Pixiv Show bookmark count

検索ページ、作者作品一覧ページなどにて、各イラストのブックマーク数を表示します。

当前为 2019-12-22 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name            Pixiv Show bookmark count
// @version         5.0.0
// @match           https://www.pixiv.net/*
// @namespace       http://greasyfork.icu/users/7945
// @description     検索ページ、作者作品一覧ページなどにて、各イラストのブックマーク数を表示します。
// ==/UserScript==

document.head.insertAdjacentHTML('beforeend', '<style>.bmcount{text-align:center!important;padding-bottom:20px!important}.JoCpVnw .bmcount{padding-bottom:0!important}.bmcount a{height:initial!important;width:initial!important;border-radius:3px!important;padding:3px 6px 3px 18px!important;font-size:12px!important;font-weight:bold!important;text-decoration:none!important;color:#0069b1!important;background-color:#cef!important;background-image:url("data:image/svg+xml;charset=utf8,<svg xmlns=%22http://www.w3.org/2000/svg%22 width=%2210%22 height=%2210%22 viewBox=%220 0 12 12%22><path fill=%22%230069B1%22 d=%22M9,1 C10.6568542,1 12,2.34314575 12,4 C12,6.70659075 10.1749287,9.18504759 6.52478604,11.4353705 L6.52478518,11.4353691 C6.20304221,11.6337245 5.79695454,11.6337245 5.4752116,11.4353691 C1.82507053,9.18504652 0,6.70659017 0,4 C1.1324993e-16,2.34314575 1.34314575,1 3,1 C4.12649824,1 5.33911281,1.85202454 6,2.91822994 C6.66088719,1.85202454 7.87350176,1 9,1 Z%22/></svg>")!important;background-position:center left 6px!important;background-repeat:no-repeat!important}</style>');
new MutationObserver(() => {
  if (/pixiv\.net\/(?:(?:en\/)?tags\/|member(?:_illust)?\.php\?id=|bookmark\.php\?id=\d+(?!.*?&type=(?:reg_)?user)|bookmark_new_illust)/.test(location.href)) var selector = document.querySelectorAll('#root div>section>ul>li,#root div>section>div>ul>li,.JoCpVnw');
  if (!selector || selector.length == document.querySelectorAll('.dummybmc').length || window != top) return;
  selector.forEach(async tarobj => {
    if (!tarobj.classList.contains('dummybmc')) tarobj.classList.add('dummybmc');
    if (tarobj.classList.contains('dummybmc2') || !tarobj.querySelector('a[href*="/artworks/"]') || tarobj.querySelector('.bmcount,.bookmark-count,a[href*="/bookmark_detail.php?illust_id="]')) return;
    tarobj.classList.add('dummybmc2');
    const illust_ID = /\d+/.exec(tarobj.querySelector('a[href*="/artworks/"]').href);
    const bmcount = (await (await fetch('https://www.pixiv.net/ajax/illust/' + illust_ID, {credentials: 'omit'})).json()).body.bookmarkCount;
    if (bmcount > 0) tarobj.insertAdjacentHTML('beforeend', '<div class="bmcount"><a href="/bookmark_detail.php?illust_id=' + illust_ID + '">' + bmcount + '</a></div>');
  });
}).observe(document.body, {childList: true, subtree: true});