Custom Modification in Wikipedia to Make Each Sentence Starts at New Line
Previously, I posted article about having each new sentence starts at new line increase readability.
We can also make Wikipedia pages to be that way for both desktop and mobile mode, as seen in screenshots below, by adding custom Javascript in user preference setting.
You will need to create Wikipedia username and login using that username to be able to store the custom Javascript.
I will also add steps to enable Dark mode and change font color to Red Orange to further enhance readability.
Sample screenshots comparison between default and new-lines pages using Wikipedia page https://en.wikipedia.org/wiki/Tensor_(machine_learning)
New-lined Mobile Mode | Default Mobile Mode | |
---|---|---|
New-lined Desktop Mode | Default Desktop Mode | |
Configuration Steps:
- Open Wikipedia, login then open User Preferences page:
- Put code below into Custom Javascript.
It adds "<br>", such as ". AAA" to ".<br>AAA" and footnote link "AAA</sup> BBB" to "AAA</sup><br>BBB"
- Change color scheme to Dark then put code below into Custom CSS to change text color to Red Orange.
- DONE.
Open a Wikipedia page to see the result.
"use strict"; mw.loader.using('mediawiki.user', function() { let paragraphtags = ["p", "td", "li"]; let newp = document.createElement("p"); for (let temptag of paragraphtags) { for (let tempobj of document.getElementsByTagName(temptag)) { tempobj.innerHTML = tempobj.innerHTML. replaceAll(". ", '. newlinemark '). replaceAll("; ", '; newlinemark '). replaceAll('." ', '." newlinemark '). replaceAll("</sup> ", '</sup> newlinemark '). replaceAll(" newlinemark (", " ("); let tempstring = ""; let wordcount = 0; for (let tempitem of tempobj.innerHTML.split(/\snewlinemark\s/)) { newp.innerHTML = tempitem; let tempvar = newp.innerText.replace(/\x5B\S+\x5D/g, ""). replace(/\x5B\S+\s+\S+\x5D/g, "").trim(); wordcount += tempvar.split(/\s+/).length; if ( wordcount > 3 && tempvar.search( /( [A-Z][^A-Z]{0,2}| etc| vs|\x2E\S|\x2E\W\S+)(\x2E|\x2E\x22|\x3B)$/ ) === -1 && tempvar.search(/(\S\S|\S\s\d+)(\x2E|\x2E\x22|\x3B)$/) !== -1 && newp.innerText.search(/\x5D\x3B$/) === -1 ) { tempstring += tempitem + "<br/>"; wordcount = 0; } else tempstring += tempitem + " "; } tempobj.innerHTML = tempstring.replaceAll("<br/><sup ", "<sup "); } } })
div, td { color: #FF4500 }
My other articles:
https://www.linkedin.com/in/zamroni/details/featured/
Comments