Last active
September 27, 2016 22:20
-
-
Save aaronjanse/45ee2df5fa4bb95452ba5ace9ca0f0ea to your computer and use it in GitHub Desktop.
Bursch Blog Cleaner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Bursch Blog Cleaner | |
// @version 1.0 | |
// @description This makes Mr.Bursch's blog legible! | |
// @author Aaron Janse | |
// @match http://mrbursch.blogspot.com/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
/* Settings */ | |
var cleanerHeader = true; // Use a cleaner font for the title | |
var removeLabelSection = true; // Remove list of labels in the sidebar | |
var removeArchive = false; // Remove blog archive in sidebar | |
var removeBackground = true; // Change this to false to blur, instead of remove, the original background. Text and sidebar contrasting is automatic | |
// The following options are for if the background is enabled: | |
var blurAmnt = 2; // Pixels | |
var brightness = 50; // Percentage | |
/* Actual Code */ | |
if (removeBackground) { | |
// Change sidebar color to light grey | |
document.querySelectorAll(".column-right-inner")[0].style.backgroundColor = "lightgrey"; | |
// Remove background image | |
document.body.style.background = "none"; | |
// Make text black in order to contrast the now white background | |
document.body.style.color = "black"; | |
// Fix link colors (change from orange to default blue) | |
var links = document.querySelectorAll(".sidebar .widget a:link"); | |
for (var i = 0; i < links.length; i++) { | |
links[i].style.color = "#0000EE"; | |
} | |
// Fix sidebar text coloring (from white to black) | |
var w = document.querySelectorAll(".sidebar .widget"); | |
for (var i = 0; i < w.length; i++) { | |
w[i].style.color = "black"; | |
} | |
} else { | |
// Blur background | |
var customStyles = document.createElement('style'); | |
// from http://stackoverflow.com/a/33091315/6496271 | |
customStyles.appendChild(document.createTextNode( | |
`body::before { | |
content: ""; | |
position: fixed; | |
left: 0; | |
right: 0; | |
z-index: -1; | |
display: block; | |
background: #010101 url(//themes.googleusercontent.com/image?id=1f-p4d2MS_T8qP_40US1-noQRizaQ_2OtaFi66bAkuKLLkaaBJGuFTmrkvYxWGgzDXvIG) no-repeat fixed top center; | |
background-size:cover; | |
width: 100%; | |
height: 100%; | |
-webkit-filter: blur(`+blurAmnt+`px); | |
-moz-filter: blur(`+blurAmnt+`px); | |
-o-filter: blur(`+blurAmnt+`px); | |
-ms-filter: blur(`+blurAmnt+`px); | |
filter: blur(`+blurAmnt+`px) brightness(`+brightness+`%); | |
} ` | |
)); | |
document.body.appendChild(customStyles); | |
document.querySelectorAll(".column-right-inner")[0].style.backgroundColor = "rgba(0, 0, 0, 0.48)"; | |
} | |
// Remove dark area around text | |
var myElements = document.querySelectorAll(".content-inner"); | |
for (var i = 0; i < myElements.length; i++) { | |
myElements[i].style.background = "none"; | |
} | |
// Remove empty sidebar area | |
document.querySelectorAll(".main-inner .fauxcolumn-right-outer .fauxcolumn-inner")[0].style.background = "none"; | |
if(removeLabelSection) { | |
document.querySelectorAll(".Label")[0].style.display = "none"; | |
} | |
if(removeArchive) { | |
document.querySelectorAll(".BlogArchive")[0].style.display = "none"; | |
} | |
// Remove extranous "Translator" header | |
document.querySelectorAll("#HTML3")[0].style.display = "none"; | |
if(cleanerHeader) { | |
document.head.innerHTML+='<link href="https://fonts.googleapis.com/css?family=Architects+Daughter" rel="stylesheet">'; | |
document.querySelectorAll(".Header h1")[0].style.fontFamily="'Architects Daughter', cursive"; | |
} | |
// Use RegEx in order to clean up posts' content | |
var content = document.querySelectorAll(".hfeed")[0].innerHTML; | |
// Replace series of dashes with one horizontal line | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/--------------------------------------------------------------------------------/g, "<hr noshade></hr>"); | |
// Change class labels to actual HTML headers | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/HONORS BIOLOGY/g, "<h3>HONORS BIOLOGY</h3>"); | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/AP ENVIRONMENTAL SCIENCE/g, "<h3>AP ENVIRONMENTAL SCIENCE</h3>"); | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/BIOLOGY/g, "<h3>BIOLOGY</h3>"); | |
// Bold and correct capitalization of "AGENDA: " | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/AGENDA:/g, "<b>Agenda:</b>"); | |
// Bold and correct capitalization of "OUTSIDE OF CLASS: " | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/OUTSIDE OF CLASS:/g, "<b>Outside of Class:</b>"); | |
// Clean up "NO CLASS TODAY..." and remove some excess whitespace | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/NO CLASS TODAY \(SEE YESTERDAY'S POST\)\s*<br>/g, "No Class Today"); | |
// Remove extra dashes | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/(\r\n|\n|\r)/gm,"").replace(/---<br>--<br>-/gm, ""); | |
// Remove extra newlines | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/(\r\n|\n|\r)/gm,"").replace(/<br>(<br>)+/gm, "<br><br>"); | |
content = document.querySelectorAll(".hfeed")[0].innerHTML = content.replace(/(\r\n|\n|\r)/gm,"").replace(/<br>No Class Today/gm, "No Class Today"); | |
// Remove blogger header | |
document.getElementById("b-navbar"); | |
document.getElementById("navbar-iframe").style.display="none"; | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To install, install the TamperMonkey extension, click "Add a new script...", then copy & paste this code into the new tab.