Last active
May 7, 2024 12:49
-
-
Save sirlaurie/5a5e7e3b906d550d94863f2a32ebc69c to your computer and use it in GitHub Desktop.
在豆瓣电影页面上给IMDb号添加rarbg搜索链接. 一键直达搜索结果页
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name 豆瓣电影RARBG搜索 | |
// @namespace http://tampermonkey.net/ | |
// @version 0.2 | |
// @description 在豆瓣电影页面添加RARBG搜索链接 | |
// @author You | |
// @match https://movie.douban.com/subject/* | |
// @grant none | |
// ==/UserScript== | |
document.addEventListener('DOMContentLoaded', | |
(function() { | |
'use strict'; | |
// 获取id为info的div标签 | |
const infoDiv = document.getElementById('info'); | |
// 获取所有br标签后面的文本节点 | |
const textNodes = Array.from(infoDiv.querySelectorAll('br')) | |
.map(br => br.nextSibling) | |
.filter(node => node && node.nodeType === Node.TEXT_NODE); | |
// 获取最后一个文本节点的值 | |
const lastTextNode = textNodes[textNodes.length - 2].nextSibling.nextSibling.data; | |
// 创建a标签 | |
const link = document.createElement('a'); | |
link.target = "new"; | |
link.href = `https://therarbg.to/get-posts/keywords:${lastTextNode.trim()}/`; | |
link.textContent = lastTextNode; | |
// 将最后一个文本节点替换为a标签 | |
infoDiv.replaceChild(link, infoDiv.lastElementChild.previousSibling); | |
})()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment