Last active
April 17, 2022 13:47
-
-
Save y-mamanaranu/5ed48690b044611b57a8d94665913cca to your computer and use it in GitHub Desktop.
Tampermonkey script for PostPrime to add hide post botton in timeline
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 PostPrime - Add Posrt Off | |
| // @namespace https://github.com/y-muen | |
| // @version 0.1.3 | |
| // @description Add hide post botton in PostPrime timeline | |
| // @author Yoiduki <y-muen> | |
| // @match *://postprime.com/* | |
| // @icon https://www.google.com/s2/favicons?domain=postprime.com | |
| // @grant none | |
| // @updateURL https://gist.github.com/y-muen/5ed48690b044611b57a8d94665913cca/raw/postprime-add-post-off.js | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| const addPostOff_sub = (elem) => { | |
| if (elem.firstChild.class !="addPostOff" ){ | |
| const res = elem.getElementsByClassName("ThreeDotsMenu_menuWrapper__9sMmL")[0]; | |
| if (res.lastChild.textContent == '投稿を非表示にする'){ | |
| var img = document.createElement("img"); | |
| img.src="/images/icons/post-off.svg"; | |
| img.alt="post-off"; | |
| img.style="margin: auto; padding: 10px;"; | |
| img.class="addPostOff"; | |
| elem.insertBefore(img, elem.firstChild); | |
| img.onclick = function(){res.lastChild.click()}; | |
| } | |
| } | |
| } | |
| const addPostOff = () => { | |
| var Post_rightSide__RYfsI = document.getElementsByClassName("Post_rightSide__RYfsI"); | |
| Post_rightSide__RYfsI = Array.from(Post_rightSide__RYfsI); | |
| Post_rightSide__RYfsI.forEach((elem) => addPostOff_sub(elem)); | |
| }; | |
| addPostOff(); | |
| const observer = new MutationObserver((mutations) => { | |
| mutations.forEach((mutation) => { | |
| addPostOff() | |
| }); | |
| }); | |
| const config = { | |
| attributes: false, | |
| childList: true, | |
| characterData: false, | |
| subtree:true | |
| }; | |
| observer.observe(document, config); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment