Last active
October 16, 2024 06:43
-
-
Save IanSmith123/c3ecf1c71ddf974dab625ce383590971 to your computer and use it in GitHub Desktop.
移除JLRS 歌单的前缀
This file contains hidden or 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 remove play list suffix | |
// @namespace http://tampermonkey.net/ | |
// @version 2024-04-21 | |
// @description 移除JRLS 歌单的前缀 | |
// @author Les1ie | |
// @match https://www.bilibili.com/video/BV* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
setTimeout(function() { | |
// 在这里放置你的油猴脚本代码 | |
// Your code here... | |
const conditionXPath = '/html/body/div[2]/div[2]/div[2]/div/div[1]/div[1]/div[2]/div[1]/div/div[1]/a[1]/text()'; | |
// 获取符合条件的元素 | |
const conditionElement = document.evaluate(conditionXPath, document, null, XPathResult.STRING_TYPE, null).stringValue; | |
// 检查条件是否满足 | |
if (conditionElement.includes("JLRS")) { | |
// 条件满足,执行油猴脚本 | |
console.log("JLRS的歌单,执行移除前缀脚本"); | |
// 获取匹配的所有元素 | |
//const xpath = '//*[@id="mirror-vdcon"]/div[2]/div/div[7]/div[1]/div[2]/div/div[1]/div/div/div[1]'; | |
const xpath = '//*[@id="mirror-vdcon"]/div[2]/div/div[6]/div[1]/div[2]/div/div/div/div/div[1]/div[2]'; | |
const elements = document.evaluate(xpath, document, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null); | |
//console.log(elements); | |
// 循环遍历每个匹配的元素 | |
for (let i = 0; i < elements.snapshotLength; i++) { | |
const element = elements.snapshotItem(i); | |
// 获取元素原始文本内容 | |
const originalText = element.textContent.trim(); | |
let modifiedText = originalText.replace("在百万豪装录音棚大声听", ""); | |
modifiedText = modifiedText.replace("百万豪装录音棚大声听", ""); | |
modifiedText = modifiedText.replace("在百万级豪华录音棚试听", ""); | |
modifiedText = modifiedText.replace("在百万级录音棚听", ""); | |
modifiedText = modifiedText.replace("百万级录音棚听", ""); | |
modifiedText = modifiedText.replace("在录音棚听", ""); | |
modifiedText = modifiedText.replace("录音棚听", ""); | |
//modifiedText = modifiedText.replace(/\s/g, ''); | |
modifiedText = String(i+1)+" "+modifiedText; | |
console.log(modifiedText); | |
// 将修改后的文本内容设置回元素 | |
element.textContent = modifiedText; | |
} | |
} else { | |
// 条件不满足,可选择执行其他操作或不执行任何操作 | |
console.log("不是JLRS的歌单,跳过移除前缀脚本"); | |
} | |
}, 5000); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment