解禁p站历史记录

为Pixiv历史记录页面上的图片添加超链接并修正透明度

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         解禁p站历史记录
// @namespace    http://greasyfork.org
// @version      0.1
// @description  为Pixiv历史记录页面上的图片添加超链接并修正透明度
// @author       You
// @match        https://www.pixiv.net/history.php
// @icon         https://www.google.com/s2/favicons?sz=64&domain=pixiv.net
// @grant        none
// @license MIT
// ==/UserScript==

(function() {
    'use strict';
    // 延迟执行
    setTimeout(function() {

        // 获取所有符合条件的 span 元素
        const items = document.querySelectorAll('span._history-item.trial');

        console.log('Found', items.length, 'items to process.');

        items.forEach(item => {
            const img = item.querySelector('img');
            if (!img) {
                console.log('No image found in item', item);
                return;
            }

            // 提取文件名中的 pid (4到10位数字)
            const src = img.src;
            const pidMatch = src.match(/(\d{4,10})_.*\.jpg/);

            if (pidMatch) {
                const pid = pidMatch[1]; // 获取提取的 pid
                console.log('Found pid:', pid);

                // 创建一个新的链接元素
                const link = document.createElement('a');
                link.href = `https://www.pixiv.net/artworks/${pid}`;
                link.target = "_blank";
                link.className = "_history-item show-detail list-item";
                link.rel = "noreferrer";
                link.style.position = "relative";

                // 选择包裹图片的 div,并将其添加到链接中
                const divContainer = item.querySelector('div'); // 选择包裹图片的 div 元素,不依赖具体类名
                if (divContainer) {
                    link.appendChild(divContainer); // 将 div 包装到链接中
                }

                // 设置图片的 opacity 为 1
                img.style.opacity = 1;

                // 替换原有的 span 元素
                item.parentNode.replaceChild(link, item);

                console.log('Replaced item with link:', link);
            } else {
                console.log('No pid match for src:', src);
            }
        });

    }, 1000);
})();