您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Redirect to the first book when searching by ISBN on Douban
// ==UserScript== // @name Douban Book Redirect // @namespace http://GitHub.com/awyugan // @version 0.2 // @description Redirect to the first book when searching by ISBN on Douban // @author awyugan // @match https://search.douban.com/book/subject_search?* // @match https://www.douban.com/search?cat=1001* // @grant none // @license MIT // ==/UserScript== (function() { 'use strict'; // Function to check if the query is an ISBN function isISBN(query) { // Remove all non-digit characters let cleaned = query.replace(/[^0-9]/g, ''); // Check if it's a valid ISBN-10 or ISBN-13 return (cleaned.length === 10 || (cleaned.length === 13 && (cleaned.startsWith('978') || cleaned.startsWith('979')))); } // Wait for the page to fully load window.addEventListener('load', function() { // Extract the search text from the URL let urlParams = new URLSearchParams(window.location.search); let searchText = urlParams.get('search_text'); if (searchText && isISBN(searchText)) { // Check if we're on the search page and if there are book results let firstBookLink = document.querySelector('.title-text'); // for the first URL if (!firstBookLink) { firstBookLink = document.querySelector('.result .title a'); // for the second URL } if (firstBookLink) { // Redirect to the first book's page window.location.href = firstBookLink.href; } } }, false); })();