🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

skrbt 磁力链接直接复制

无需进入详情页即可直接复制磁力链接,仅 skrbtuo.top 域名有效

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

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

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

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

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

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

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

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

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

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

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

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

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         skrbt 磁力链接直接复制
// @namespace    http://tampermonkey.net/
// @version      0.0.1
// @description  无需进入详情页即可直接复制磁力链接,仅 skrbtuo.top 域名有效
// @author       You
// @match        https://skrbtuo.top/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=skrbtuo.top
// @grant        none
// @license MIT
// ==/UserScript==

;(() => {
	//新增一个表格列
	const domList = document.querySelectorAll(
		"body > div.container-fluid > div:nth-child(6) > div.col-md-6 > ul"
	)
	for (let item of domList) {
		const childDom = item.querySelector("li:nth-child(1)")
		//获取请求url
		const childDom2 = childDom.querySelector("a")
		const url = "https://skrbtuo.top" + childDom2.getAttribute("href")
		const cookies = document.cookie
		//往元素的末尾插入元素
		const btn = document.createElement("div")
		btn.style.color = "blue"
		btn.style.cursor = "pointer"
		btn.style.textDecoration = "underline"
		btn.innerText = "磁力链接"
		btn.style.textAlign = "right"
		//发送url地址的请求,抓取其中的磁力链
		btn.onclick = () => {
			btn.innerText = "加载中..."
			const headers = new Headers()
			headers.append("Cookie", cookies)
			fetch(url, {
				headers: headers,
			})
				.then((res) => res.text())
				.then((res) => {
					//通过正则匹配,获取磁力链
					const reg = /magnet:\?xt=urn:btih:[0-9a-fA-F]{40}/
					const result = res.match(reg)
					if (result && result.length > 0 && result[0]) {
						btn.style.color = "darkred"
						btn.innerText = "已复制到剪切板"
						//复制到剪切板
						const input = document.createElement("input")
						input.value = result[0]
						input.style.position = "fixed"
						input.style.opacity = "0"
						document.body.appendChild(input)
						input.select()
						document.execCommand("copy")
						document.body.removeChild(input)
					} else {
						btn.innerText = "出错了,请刷新页面"
					}
				})
		}
		childDom.appendChild(btn)
	}
})()