Last active
April 17, 2022 13:48
-
-
Save y-mamanaranu/383402f28b42097c5fa2d27d5c39982d to your computer and use it in GitHub Desktop.
Tampermonkey script for PostPrime to Expand Text Field 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 - Expand Text Field | |
| // @namespace https://github.com/y-muen | |
| // @version 0.1.3 | |
| // @description Expand Text Field in PostPrime timeline | |
| // @author Yoiduki <y-muen> | |
| // @include *://postprime.com/* | |
| // @exclude *://postprime.com/*/post/* | |
| // @icon https://www.google.com/s2/favicons?domain=postprime.com | |
| // @grant GM_addStyle | |
| // @updateURL https://gist.github.com/y-muen/383402f28b42097c5fa2d27d5c39982d/raw/postprime-expand-text-field.js | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| GM_addStyle(".Post_text__cLvqu {-webkit-line-clamp:1000!important;}"); | |
| const expandTextField_sub = (elem) => { | |
| if (!elem.classList.contains('expandTextField')){ | |
| var innerHTML = elem.innerHTML.replaceAll(/\n\n+/g, "\n\n"); | |
| if(innerHTML != elem.innerHTML) { | |
| elem.innerHTML = innerHTML; | |
| } | |
| elem.classList.add('expandTextField'); | |
| } | |
| } | |
| const expandTextField = function() { | |
| var richcontent = document.getElementsByClassName('richcontent') | |
| richcontent = Array.from(richcontent); | |
| richcontent.forEach( elem => expandTextField_sub(elem)); | |
| } | |
| expandTextField(); | |
| const observer = new MutationObserver((mutations) => { | |
| mutations.forEach((mutation) => { | |
| expandTextField() | |
| }); | |
| }); | |
| 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