Last active
September 1, 2021 20:35
-
-
Save thekalinga/76c83c52febf33b7a1f2ddbf976efbac to your computer and use it in GitHub Desktop.
indianexpress cleanup
This file contains 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 indianexpress cleanup | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @author You | |
// @match https://indianexpress.com/article/* | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function undo() { | |
removeClass(document.getElementsByTagName('body')[0], 'toggle'); | |
toggle.src = showNavIcon; | |
} | |
function apply() { | |
addClass(document.getElementsByTagName('body')[0], 'toggle'); | |
toggle.src = hideNavIcon; | |
} | |
var showing = false; | |
var hideNavIcon = 'data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiIHN0YW5kYWxvbmU9Im5vIj8+DQo8c3ZnDQogICB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciDQogICB3aWR0aD0iMTAwJSINCiAgIGhlaWdodD0iMTAwJSINCiAgIHZpZXdCb3g9IjAgMCAyMDQ4IDE3OTIiPg0KICA8cGF0aA0KICAgICBkPSJNMCA4OTZxMC0xMzAgNTEtMjQ4LjV0MTM2LjUtMjA0IDIwNC0xMzYuNSAyNDguNS01MWg3NjhxMTMwIDAgMjQ4LjUgNTF0MjA0IDEzNi41IDEzNi41IDIwNCA1MSAyNDguNS01MSAyNDguNS0xMzYuNSAyMDQtMjA0IDEzNi41LTI0OC41IDUxaC03NjhxLTEzMCAwLTI0OC41LTUxdC0yMDQtMTM2LjUtMTM2LjUtMjA0LTUxLTI0OC41ek0xNDA4IDE0MDhxMTA0IDAgMTk4LjUtNDAuNXQxNjMuNS0xMDkuNSAxMDkuNS0xNjMuNSA0MC41LTE5OC41LTQwLjUtMTk4LjUtMTA5LjUtMTYzLjUtMTYzLjUtMTA5LjUtMTk4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jUtMjA0IDIwNC0xMzYuNSAyNDguNS01MWg3NjhxMTMwIDAgMjQ4LjUgNTF0MjA0IDEzNi41IDEzNi41IDIwNCA1MSAyNDguNXoiLz48L3N2Zz4='; | |
var toggle = document.createElement('img'); | |
toggle.src = hideNavIcon; | |
toggle.style.position = 'fixed'; | |
toggle.style.bottom = "10px"; | |
toggle.style.right = "10px"; | |
toggle.style.width = "20px"; | |
toggle.style.height = "20px"; | |
toggle.style.cursor = "pointer"; | |
toggle.style.zIndex = "9999"; | |
toggle.addEventListener("click", function() { | |
if (!showing) { | |
apply(); | |
} else { | |
undo(); | |
} | |
showing = !showing; | |
}); | |
document.getElementsByTagName('body')[0].appendChild(toggle); | |
var newStyleToBeApplied = document.createElement('style'); | |
newStyleToBeApplied.type= 'text/css'; | |
newStyleToBeApplied.innerHTML = ` | |
.toggle .leftpanel | |
{ | |
width: 100% !important; | |
} | |
.toggle .full-details p { | |
font-family: Crimson Pro Light; | |
font-size: 20px; | |
} | |
.toggle .common, | |
.toggle .breaking-scroll, | |
.toggle .rightpanel, | |
.toggle .share-social, | |
.toggle .breaking-news, | |
.toggle footer, | |
.toggle header, | |
.toggle .appstext, | |
.toggle .copyright, | |
.toggle .storytags, | |
.toggle .abbott-disc, | |
.toggle .more-from, | |
.toggle .social-icon, | |
.toggle .topmenubx, | |
.toggle .m-marquee, | |
.toggle .ie-adsbox, | |
.toggle .app-btn, | |
.toggle #comments, | |
.toggle .breaking-scroll, | |
.toggle .epaper-banner, | |
.toggle .ptop, | |
.toggle p strong, | |
.toggle p em strong, | |
.toggle .embed-youtube, | |
.toggle .pdsc-related-modify, | |
.toggle .ie-int-campign-ad, | |
.toggle .custom_read_button, | |
.toggle .pune-related-widget, | |
.toggle iframe | |
{ | |
display: none !important; | |
} | |
`; | |
document.getElementsByTagName('head')[0].appendChild(newStyleToBeApplied); | |
apply(); | |
showing = !showing; | |
function hasClass(el, className) { | |
if (el.classList) { | |
return el.classList.contains(className); | |
} else { | |
return !!el.className.match(new RegExp('(\\s|^)' + className + '(\\s|$)')); | |
} | |
} | |
function addClass(el, className) { | |
if (el.classList) { | |
el.classList.add(className); | |
} | |
else if (!hasClass(el, className)) { | |
el.className += " " + className; | |
} | |
} | |
function removeClass(el, className) { | |
if (el.classList) { | |
el.classList.remove(className); | |
} else if (hasClass(el, className)) { | |
var reg = new RegExp('(\\s|^)' + className + '(\\s|$)'); | |
el.className=el.className.replace(reg, ' '); | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment