話題を検索タブで表示される「Grokによる要約」を削除します
// ==UserScript==
// @name 検索結果からGrokの要約を消す
// @namespace https://armedpatriot.blog.fc2.com/
// @version 2025-01-23
// @description 話題を検索タブで表示される「Grokによる要約」を削除します
// @author Patriot
// @match https://x.com/search*
// @icon https://www.google.com/s2/favicons?sz=64&domain=x.com
// @grant none
// @run-at document-idle
// ==/UserScript==
(function() {
'use strict';
const observer = new MutationObserver((mutationList, observer) =>{
mutationList.forEach((mutation)=>{
if (mutation.type === 'childList'){
const descriptionText = "Grokによる要約";
let descriptionElement;
Array.from(document.getElementsByTagName("span")).forEach(
e => {
if(e.textContent === descriptionText){
descriptionElement = e;
}
}
);
if(descriptionElement === undefined){
return;
}
const containerElement = descriptionElement?.parentElement?.parentElement?.parentElement?.parentElement;
if(containerElement === undefined){
console.log(`cannot find containerElement: descriptionElement=${descriptionElement}`);
return;
}
containerElement.remove();
console.log("removed Grok summary");
}
});
});
observer.observe(
document.body,
{
attributes: false,
childList: true,
subtree: true
}
);
})();