Bookfusion: Bookshelf UI Modifier

Replace the first disabled bookshelf header div with one that has a data-action attribute

当前为 2025-08-02 提交的版本,查看 最新版本

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Bookfusion: Bookshelf UI Modifier
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  Replace the first disabled bookshelf header div with one that has a data-action attribute
// @match        https://www.bookfusion.com/bookshelf*
// @license MIT
// ==/UserScript==

(function () {
  'use strict';

  function updateHeaderDiv() {
    const headerDiv = document.querySelector('div.bookshelf-expandable-header-details.is-disabled');
    if (headerDiv) {
      headerDiv.classList.remove('is-disabled');
      headerDiv.setAttribute('data-action', 'click->horizontal-book-list#toggleAction');
      console.log('✅ Header div updated');
    } else {
      console.log('⚠️ No disabled header div found');
    }
  }

  function updateExpandableDivs() {
    const divs = document.querySelectorAll('div.bookshelf-expandable');
    if (divs.length === 0) {
      console.log('⚠️ No bookshelf-expandable divs found');
      return;
    }

    divs.forEach((div, index) => {
      if (index === 0) {
        div.classList.remove('is-expanded');
      } else {
        div.classList.add('is-expanded');
        //div.classList.remove('is-expanded');
      }
    });
    console.log(`✅ Updated ${divs.length} expandable div(s)`);
  }

  // Run once on full page load (in case of slow content)
  window.addEventListener('load', () => {
    updateHeaderDiv();
    updateExpandableDivs();
  });

})();