Greasy Fork

来自缓存

Greasy Fork is available in English.

拷贝漫画书架显示上次观看章节

我的书架中展示上次阅读章节,并可以直接跳转阅读。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         拷贝漫画书架显示上次观看章节
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  我的书架中展示上次阅读章节,并可以直接跳转阅读。
// @author       xx
// @match        *://*.copymanga.com/*
// @match        *://*.copymanga.org/*
// @match        *://*.copymanga.net/*
// @match        *://*.copymanga.info/*
// @match        *://*.copymanga.site/*
// @match        *://*.copymanga.tv/*
// @match        *://copymanga.com/*
// @match        *://copymanga.org/*
// @match        *://copymanga.net/*
// @match        *://copymanga.info/*
// @match        *://copymanga.site/*
// @match        *://copymanga.tv/*
// @icon         data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    const OriginalXMLHttpRequest = window.XMLHttpRequest;

    window.XMLHttpRequest = function() {
        const xhr = new OriginalXMLHttpRequest();

        xhr.addEventListener('readystatechange', function() {
            if (xhr.readyState === 4) {
                const url = xhr.responseURL;
                if (!url.includes('/member/collect/comics')) return;
                const response = JSON.parse(xhr.response);
                const list = response.results.list.map(item => ({ ...(item.last_browse || {}), path_word: item.comic.path_word }));
                changeView(list)
            }
        });

        return xhr;
    };

    function changeView(list) {
        setTimeout(() => {
          const main = document.getElementsByClassName('man_')[0];
           Array.from(main.children).forEach((child, index) => {
               child.style.position = 'relative';
               const current = list[index];
               const lastP = child.querySelector(`#${current.path_word}`);
               if (lastP) child.removeChild(lastP);
               const p = document.createElement('p');
               p.id = current.path_word;
               p.innerHTML = current.last_browse_id ? `<a href="/comic/${current.path_word}/chapter/${current.last_browse_id}" target='_blank'>上次阅读:  ${current.last_browse_name}</a>` : '还没看过';
               p.style.width = '100%';
               p.style.position = 'absolute';
               p.style.bottom = '10px';
               child.appendChild(p);
          })
        }, 0)
    }
})();