DPRA-ify

Singing praises to our Beloved Sun of the Rocky Mountains, Donald J. Trump, Supreme Leader to the Democratic People's Republic of America.

目前為 2025-03-11 提交的版本,檢視 最新版本

// ==UserScript==
// @name        DPRA-ify
// @namespace   io.github.poneyclairdelune.dpra
// @match       https://whitehouse.gov/*
// @match       https://www.whitehouse.gov/*
// @run-at      document-idle
// @grant       none
// @version     0.0.2
// @author      Lumière Élevé
// @homepageURL https://github.com/PoneyClairDeLune/DPRA-ify
// @supportURL  https://github.com/PoneyClairDeLune/DPRA-ify/issues
// @description Singing praises to our Beloved Sun of the Rocky Mountains, Donald J. Trump, Supreme Leader to the Democratic People's Republic of America.
// @license     WTFPL
// ==/UserScript==
"use strict";(()=>{let f=class{isMatch=!1;pos=0;data;constructor(e,a,t){this.isMatch=e,this.pos=a,this.data=t}},p=class extends Array{constructor(...e){super(...e)}static sorter(e,a){return e.pos-a.pos}sort(e){e||(e=p.sorter),super.sort(e)}},b=class{static buildMatchCache(e){let a={};for(let t of e)a[t]=!0;return a}static match(e,a){let t=new p;for(let l in a){let o=0,i=0,h=-1;do{let d=e.substring(o).indexOf(l),c=d+o;if(d===-1)break;if(c==h)break;t.push(new f(!0,c,l)),o+=d+l.length,h=c,i++}while(o>=0&&o<e.length&&i<16)}t.sort();let n=t.length,r=0;for(let l=0;l<n;l++){let o=t[l];t.push(new f(!1,r,e.substring(r,o.pos))),r=o.pos+o.data.length}return r+1!==e.length&&t.push(new f(!1,r,e.substring(r))),t.sort(),t}},u=b;let m=`p>span.dpra-text,li>span.dpra-text{font-size:1.5rem;font-weight:550;text-decoration:underline 2px}strong>span.dpra-text{font-size:1.5rem}
`;let s={"Donald ":"Donald","J. ":"J.","Trump ":"Trump","Vice ":"Second to","US ":"DPRA","U.S. ":"D.P.R.A.","United States ":"Democratic People's Republic","United States of America ":"Democratic People's Republic of America","President ":[["","Our"],["","Great","Supreme","Beloved","Dear","Glorious","Graceful","Selfless","Strong-willed"],["","Great","Supreme","Beloved","Dear","Glorious","Graceful","Selfless","Strong-willed"],["Leader","Comrade","General","Commander","Marshal","Sun of Mt. Paektu","Rising Sun of the Rocky Mountains","Shining Star of the Appalachian Mountains","Child of God","God","Saviour"]]};let x=[];for(let e in s)x.push(e);for(let e of x)switch(e){case"US ":case"U.S. ":case"Donald ":case"J. ":case"Trump ":break;case"President ":{s[e.toUpperCase()]=s[e];break}default:s[e.toUpperCase()]=s[e],s[e.toLowerCase()]=s[e]}let g=(e,a=1)=>{switch(typeof s[e]){case"string":return s[e];case"object":{let t=[],n=Math.floor(Math.random()*a);for(let r=0;r<=n;r++){let l=[];for(let o of s[e]){let i=o[Math.floor(Math.random()*o.length)];i?.length>0&&l.push(i)}t.push(l.join(" "))}return t.join(", ")}}};(()=>{let e=document.createElement("style");e.classList.add("dpra-css"),e.innerHTML=m,document.head.append(e)})();let S=[];for(let e of document.querySelectorAll("p, a, h1, h2, h3, h4, h5, h6, li, strong")){let a=!1;for(let t of e.childNodes){if(t.nodeType===3){for(let n in s)if(t.data.indexOf(n)!==-1&&(a=!0),a)break}if(a)break}a&&S.push(e)}for(let e of S){let a=[];for(let t of e.childNodes)a.push(t);for(;e.childNodes.length>0;)e.childNodes[0].remove();for(let t of a)if(t.nodeType===3){let n=u.match(t.data,s);for(let r of n)if(console.debug(r),r.isMatch){let l=document.createElement("span");switch(location.href.indexOf("/articles/")!==-1&&l.classList.add("dpra-text"),r.data){case"President ":case"PRESIDENT ":{l.append(`${g(r.data,4)} `);break}default:l.append(`${g(r.data)} `)}e.append(l)}else e.append(document.createTextNode(r.data))}else e.append(t)}})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址