您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
在豆瓣电影h1标题内末尾添加美化跳转按钮
当前为
// ==UserScript== // @name 豆瓣电影跳转 // @namespace http://tampermonkey.net/ // @version 0.33 // @description 在豆瓣电影h1标题内末尾添加美化跳转按钮 // @author JIEMO // @match *://movie.douban.com/subject/* // @icon https://www.google.com/s2/favicons?domain=douban.com // @grant none // @license GPL-3.0-or-later; https://www.gnu.org/licenses/gpl-3.0.txt // ==/UserScript== (function() { 'use strict'; // 使用MutationObserver确保动态加载的内容也能被处理 const observer = new MutationObserver(function(mutations) { const h1Element = document.querySelector('h1'); if (h1Element && !h1Element.querySelector('.douban-jump-btn')) { addButtonToH1(h1Element); } }); observer.observe(document.body, { childList: true, subtree: true }); function addButtonToH1(h1Element) { // 获取标题文本 const titleSpan = h1Element.querySelector('span[property="v:itemreviewed"]'); if (!titleSpan) return; let titleText = titleSpan.textContent.trim(); // 截断标题文本,取第一个空格前的内容 titleText = titleText.split(' ')[0]; // 创建按钮容器(保持与标题文本的间距) const btnContainer = document.createElement('span'); btnContainer.style.display = 'inline-block'; btnContainer.style.marginLeft = '12px'; // 创建第一个跳转按钮 const jumpButton1 = document.createElement('a'); jumpButton1.href = `https://www.gying.si/s/1---1/${encodeURIComponent(titleText)}`; jumpButton1.target = '_blank'; // 添加此行,使链接在新窗口打开 jumpButton1.textContent = 'gying'; jumpButton1.className = 'douban-jump-btn'; // 创建第二个跳转按钮 const jumpButton2 = document.createElement('a'); jumpButton2.href = `https://tv.kanpian.club/s/${encodeURIComponent(titleText)}.html`; jumpButton2.target = '_blank'; // 添加此行,使链接在新窗口打开 jumpButton2.textContent = '看片咖'; jumpButton2.className = 'douban-jump-btn'; jumpButton2.style.marginLeft = '8px'; // 为第二个按钮添加左边距 // 添加按钮样式 if (!document.querySelector('.douban-btn-style')) { const style = document.createElement('style'); style.className = 'douban-btn-style'; style.textContent = ` .douban-jump-btn { padding: 3px 10px; border: 1px solid #1565C0; border-radius: 3px; text-decoration: none; color: white; font-size: 18px; font-weight: normal; box-shadow: 0 1px 2px rgba(0,0,0,0.1); transition: all 0.2s ease; display: inline-block; vertical-align: middle; line-height: 1.5; } .douban-jump-btn:hover { background: linear-gradient(to bottom, #64B5F6, #42A5F5); box-shadow: 0 2px 4px rgba(0,0,0,0.15); transform: translateY(-1px); } .douban-jump-btn:active { transform: translateY(0); box-shadow: none; } `; document.head.appendChild(style); } // 组装元素 btnContainer.appendChild(jumpButton1); btnContainer.appendChild(jumpButton2); h1Element.appendChild(btnContainer); // 调整h1原有样式 h1Element.style.whiteSpace = 'nowrap'; h1Element.style.overflow = 'hidden'; h1Element.style.textOverflow = 'ellipsis'; } // 初始检查 const h1Element = document.querySelector('h1'); if (h1Element) { addButtonToH1(h1Element); } })();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址