Skip to content

Commit

Permalink
Most of this can be done with CSS by forcing a CSS reload in the JS
Browse files Browse the repository at this point in the history
Closes #4
  • Loading branch information
scotchi committed Mar 25, 2011
1 parent ddb4416 commit 01333cc
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 41 deletions.
37 changes: 37 additions & 0 deletions wikipedia-beautifier.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,40 @@
#mw-head:hover, #mw-panel:hover {
opacity: 1;
}

#firstHeading {
font-family: "minion-pro-1", "minion-pro-2", Palatino, Georgia, "Times New Roman", serif;
width: 900px;
margin-left: auto;
margin-right: auto;
padding-top: 0.25em;
padding-bottom: 0.25em;
border: none;
font-weight: bold;
}


#bodyContent {
line-height: 1.55em;
font-size: 1.0em;
font-family: "minion-pro-1", "minion-pro-2", Palatino, Georgia, "Times New Roman", serif;
border: 1px solid #ccc;
width: 800px;
padding: 50px;
margin-left: auto;
margin-right: auto;
margin-top: 1em;
background: #fbfbfb;
}

.infobox,
.tright, .tleft, div.tright, div.tleft,
.taxobox, table.taxobox,
.wikitable {
margin-top: 0;
margin-bottom: 0.5em;
}

.ambox, table.ambox {
margin: 1.5em 10%;
}
53 changes: 12 additions & 41 deletions wikipedia-beautifier.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,16 @@
function wiknifier()
function beautifier()
{
var fonts = '"minion-pro-1", "minion-pro-2", Palatino, Georgia, "Times New Roman", serif';

var firstHeading = document.getElementById("firstHeading");
firstHeading.style.fontFamily = fonts;
firstHeading.style.width = "900px";
firstHeading.style.marginLeft = firstHeading.style.marginRight = "auto";
firstHeading.style.paddingTop = firstHeading.style.paddingBottom = "0.25em";
firstHeading.style.border = "none";
firstHeading.style.fontWeight = "bold";
function insertCSS(url)
{
var head = document.getElementsByTagName("head")[0];
var css= document.createElement("link");
css.type = "text/css";
css.rel = "stylesheet";
css.href = url;
head.appendChild(css);
}

var bodyContent = document.getElementById("bodyContent");
bodyContent.style.lineHeight = "1.55em";
bodyContent.style.fontSize = "1.0em";
bodyContent.style.fontFamily = fonts;
bodyContent.style.border = "1px solid #ccc";
bodyContent.style.width = "800px";
bodyContent.style.padding = "50px";
bodyContent.style.marginLeft = bodyContent.style.marginRight = "auto";
bodyContent.style.marginTop = "1em";
bodyContent.style.background = "#fbfbfb";
insertCSS(chrome.extension.getURL("wikipedia-beautifier.css"));

function parentDiv(element)
{
Expand All @@ -45,26 +36,6 @@ function wiknifier()

Hyphenator.run();

var amboxes = document.getElementsByClassName("ambox");

for(var i = 0; i < amboxes.length; i++)
{
amboxes[i].style.margin = "1.5em 10%";
}

var boxClasses = [ "infobox", "tright", "tleft", "taxobox", "wikitable" ];

for(var i = 0; i < boxClasses.length; i++)
{
var boxes = document.getElementsByClassName(boxClasses[i]);

for(var j = 0; j < boxes.length; j++)
{
boxes[j].style.marginTop = 0;
boxes[j].style.marginBottom = "0.5em";
}
}

var refs = document.getElementsByClassName("references-column-width");

for(var i = 0; i < refs.length; i++)
Expand All @@ -73,4 +44,4 @@ function wiknifier()
}
}

wiknifier();
beautifier();

0 comments on commit 01333cc

Please sign in to comment.