Pixiv Show bookmark count

Displays the number of bookmarks for each illustration on the search page, author work list page, etc.

As of 2020-01-08. See the latest version.

// ==UserScript==
// @name            Pixiv Show bookmark count
// @name:zh-CN      Pixiv 显示每个插图的书签数量
// @name:zh-TW      Pixiv 顯示每個插圖的書籤數量
// @version         5.0.1
// @match           https://www.pixiv.net/*
// @namespace       https://greasyfork.dpdns.org/users/7945
// @description        検索ページ、作者作品一覧ページなどにて、各イラストのブックマーク数を表示します。
// @description:en     Displays the number of bookmarks for each illustration on the search page, author work list page, etc.
// @description:zh-CN  在搜索页面,作者工作列表页面等上显示每个插图的书签数量。
// @description:zh-TW  在搜索頁面,作者工作列表頁面等上顯示每個插圖的書籤數量。
// ==/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\/|users\/(?!\d+\/(?:follow|mypixiv))|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});
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元