Last active
April 25, 2022 19:36
-
-
Save joshparkerj/8d52e155cf7adf7f66bec7d6fa94838a to your computer and use it in GitHub Desktop.
twist the text for a zany effect
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 Zanyify | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description twist the text for a zany effect | |
| // @author Josh Parker | |
| // @source https://github.com/joshparkerj/silly-internet-tricks/blob/main/text-effect/zanyify.user.js | |
| // @downloadURL https://gist.github.com/joshparkerj/8d52e155cf7adf7f66bec7d6fa94838a/raw/zanyify.user.js | |
| // @updateURL https://gist.github.com/joshparkerj/8d52e155cf7adf7f66bec7d6fa94838a/raw/zanyify.meta.js | |
| // @match https://www.washingtonpost.com/* | |
| // @match https://www.google.com/* | |
| // @match https://en.wikipedia.org/wiki/* | |
| // @match https://www.tampermonkey.net/* | |
| // @icon https://www.google.com/s2/favicons?domain=washingtonpost.com | |
| // @grant none | |
| // ==/UserScript== |
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 Zanyify | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description twist the text for a zany effect | |
| // @author Josh Parker | |
| // @source https://github.com/joshparkerj/silly-internet-tricks/blob/main/text-effect/zanyify.user.js | |
| // @downloadURL https://gist.github.com/joshparkerj/8d52e155cf7adf7f66bec7d6fa94838a/raw/zanyify.user.js | |
| // @updateURL https://gist.github.com/joshparkerj/8d52e155cf7adf7f66bec7d6fa94838a/raw/zanyify.meta.js | |
| // @match https://www.washingtonpost.com/* | |
| // @match https://www.google.com/* | |
| // @match https://en.wikipedia.org/wiki/* | |
| // @match https://www.tampermonkey.net/* | |
| // @icon https://www.google.com/s2/favicons?domain=washingtonpost.com | |
| // @grant none | |
| // ==/UserScript== | |
| (()=>{"use strict";function e(e){e.style.setProperty("transform",`rotate(${Math.random()/5-.1}turn)`),e.style.setProperty("display","inline-block")," "===e.textContent&&e.style.setProperty("padding","0 .25em")}!function(e,t,n){const o=document.querySelector("body > div.josh-text-manips"),s=o||document.createElement("div");s.className="josh-text-manips",s.appendChild(function(e,t,n){const o=document.querySelector("body"),s=document.createElement("button");s.innerText=e;const d=function e({target:d}){const r=d;o.removeEventListener("mousedown",e);const a=r.textContent.split("").map((e=>{const t=document.createElement("span");return t.textContent=e,t}));r.textContent="",a.forEach((e=>r.appendChild(e)));const c=({target:e})=>{"SPAN"===e.tagName&&e.classList.add("selected")};r.addEventListener("mouseover",c);const i=()=>{r.removeEventListener("mouseup",i),r.removeEventListener("mouseover",c);const e=r.textContent,o=[...r.childNodes].map((e=>e.className)),d=o.indexOf("selected"),a=o.lastIndexOf("selected")+1;r.innerHTML="",r.appendChild(new Text(e.slice(0,d)));const l=document.createElement("span");l.className=t,l.appendChild(new Text(e.slice(d,a))),r.appendChild(l),r.appendChild(new Text(e.slice(a))),n(r.querySelector(`span.${t}`)),s.removeAttribute("disabled")};r.addEventListener("mouseup",i)};return s.addEventListener("click",(()=>{s.setAttribute("disabled",!0),o.addEventListener("mousedown",d)})),s}(e,t,n)),o||document.querySelector("body").appendChild(s),document.styleSheets[0].insertRule(".josh-text-manips {position: fixed;background-color: lightgrey;padding: 5px 10px;top: 62px;right: 10px;border-radius: 16px;box-shadow: 2px 2px 1px black;}")}("zanyify","zany-text",(t=>function(e,t){const n=e,o=n.textContent.length,s=n.textContent.split("").map(((e,n)=>{const s=document.createElement("span");return s.textContent=e,t(s,n,o),s}));n.textContent="",s.forEach((e=>n.appendChild(e)))}(t,e)))})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment