Created
August 20, 2022 17:49
-
-
Save imteekay/bbedd20001edff1b49188393ea5da66f to your computer and use it in GitHub Desktop.
Revisions
-
imteekay created this gist
Aug 20, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ // Remove left and right content const main = document.getElementsByTagName('main')[0]; const body = document.getElementsByTagName('body')[0]; const newBody = document.createElement('body'); newBody.appendChild(main); body.replaceWith(newBody); // Remove "More From Author" in the footer function getAllTagsWithText(tag, text) { return [...document.querySelectorAll(tag)].filter((element) => element.textContent.includes(text), ); } function getMoreFromAuthorWrapper(tag) { return tag.parentElement.parentElement.parentElement.parentElement .parentElement.parentElement.parentElement.parentElement; } const anchors = getAllTagsWithText('a', 'More from'); const moreFromAnchor = anchors[0]; const moreFromAuthorWrapper = getMoreFromAuthorWrapper(moreFromAnchor); moreFromAuthorWrapper.remove(); // Remove Footer and Header function removeTag(tag) { document.getElementsByTagName(tag)[0].remove(); } removeTag('footer'); removeTag('header'); // Remove actions: update, comment const actions = document.getElementsByClassName('pw-multi-vote-icon')[0]; const actionsWrapper = actions.parentElement.parentElement.parentElement; actionsWrapper.remove();