It's in the name
当前为
// ==UserScript==
// @name Hide youtube theather mode button
// @version 2.0
// @description It's in the name
// @author equmaq
// @match https://www.youtube.com/*
// @grant none
// @license MIT
// @namespace https://greasyfork.org/users/990886
// ==/UserScript==
(function() {
'use strict';
// Define the full XPath of the element you want to delete
const xpathToDelete = "/html/body/ytd-app/div[1]/ytd-page-manager/ytd-watch-flexy/div[5]/div[1]/div/div[1]/div[2]/div/div/ytd-player/div/div/div[29]/div[2]/div[2]/button[13]";
// Function to delete the element
function deleteElementByXPath(xpath) {
const element = document.evaluate(xpath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (element) {
element.remove();
}
}
// Initial deletion
deleteElementByXPath(xpathToDelete);
// Monitor for element recreation using MutationObserver
const observer = new MutationObserver(function(mutations) {
mutations.forEach(function(mutation) {
if (mutation.type === 'childList') {
// Check if the element has been recreated
const recreatedElement = document.evaluate(xpathToDelete, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
if (recreatedElement) {
// Delete the recreated element
recreatedElement.remove();
}
}
});
});
// Start observing the document for changes
observer.observe(document, { childList: true, subtree: true });
})();