[ prog / sol / mona ]

prog


What are you working on?

187 2023-02-03 11:43

To expand the abridged entries on https://upjoke.com/programming-jokes with the site's scripts blocked:

(() => {
  const text = Array.from (document.getElementsByTagName ("script")).map (e => e.innerText.match (/^window[.]restOfLongJokes = ([{].+[}]);$/)).filter (m => m != null) [0][1]
  const rest = JSON.parse (text)
  Array.from (document.querySelectorAll ("button[onclick]")).map (e => [e, e.getAttribute ("onclick").match (/innerHTML = restOfLongJokes\['([^']+)'\];/)]).filter (em => em [1] != null).map (([e, m]) => [e, m [1]]).forEach (([e, id]) => {
    e.previousSibling.remove ()
    e.outerHTML = rest [id]
  })
  Array.from (document.querySelectorAll (".offensive-wall")).forEach (e => e.remove ())
  Array.from (document.querySelectorAll (".joke-content.offensive")).forEach (e => e.setAttribute ("class", e.getAttribute ("class").replace (/\boffensive\b/, "")))
}) ()
199


VIP:

do not edit these