Skip to content

Commit

Permalink
Add in hypehnation and justified text.
Browse files Browse the repository at this point in the history
  • Loading branch information
scotchi committed Mar 22, 2011
1 parent f87a596 commit 405eb5c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 3 deletions.
25 changes: 25 additions & 0 deletions hyphenator.js

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions manifest.json
Expand Up @@ -4,8 +4,9 @@
"description": "Increases font sizes and rearranges layout to make wikipedia more readable",
"content_scripts": [
{
"matches": [ "http://en.wikipedia.org/*" ],
"js": [ "wiknifier.js" ]
"matches": [ "http://*.wikipedia.org/wiki/*" ],
"js": [ "hyphenator.js", "wiknifier.js" ],
"run_at": "document_end"
}
]
}
24 changes: 23 additions & 1 deletion wiknifier.js
Expand Up @@ -21,6 +21,29 @@ function wiknifier()
bodyContent.style.marginTop = "1em";
bodyContent.style.background = "#fbfbfb";

function parentDiv(element)
{
return (!element.parentNode || element.parentElement.tagName == "DIV") ?
element.parentNode : parentDiv(element.parentNode);
}

function paragraphAdjuster(elements)
{
for(var i = 0; i < elements.length; i++)
{
if(parentDiv(elements[i]) == bodyContent)
{
elements[i].className += "hyphenate";
elements[i].style.textAlign = "justify";
}
}
}

paragraphAdjuster(bodyContent.getElementsByTagName("p"));
paragraphAdjuster(bodyContent.getElementsByTagName("li"));

Hyphenator.run();

var refLists = document.getElementsByClassName("reflist");

for(var i = 0; i < refLists.length; i++)
Expand Down Expand Up @@ -83,4 +106,3 @@ function wiknifier()
}

wiknifier();

0 comments on commit 405eb5c

Please sign in to comment.