// ==UserScript==
// @name New script - qq.com
// @namespace Violentmonkey Scripts
// @match https://y.qq.com/n/ryqq/player
// @grant none
// @version 1.0
// @author -
// @description 2021/10/21 下午3:19:39
// ==/UserScript==
(function() {
'use strict';
window.onload = function() {
setInterval(() => {
if(document.querySelector('p[class="on"]')){
// console.log(document.querySelector('p[class="on"]').innerText);
var doc = new DOMParser().parseFromString(document.querySelector('p[class="on"]').innerText, "text/html");
document.title= doc.documentElement.textContent;
// document.title=document.querySelector('p[class="on"]').innerText;
}
}, 500);
// var observer = new MutationObserver(function (mutationRecordList, observer) {//https://stackoverflow.com/a/61511955/1485853
// for(const mutation of mutationRecordList) {
// if (mutation.type === 'childList') {
// console.log('A child node has been added or removed.');
// }
// else if (mutation.type === 'attributes') {
// console.log('The ' + mutation.attributeName + ' attribute was modified.');
// }
// }
// if(document.querySelector('p[class="on"]')){
// console.log(document.querySelector('p[class="on"]').innerText);
// document.title=document.querySelector('p[class="on"]').innerText;
// }
// });
// observer.observe(document.querySelector('.song_info__lyric_inner'), {subtree: true, childList: true});
};
})();
这是一个JavaScript用户脚本,用于监听页面加载并在找到特定类名为''on'的段落元素时,将其文本内容设置为页面标题。脚本使用了setInterval定时检查并更新页面标题,同时注释中提到了MutationObserver,但未实际使用来监听DOM变化。
5901

被折叠的 条评论
为什么被折叠?



