NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name ZeroCruft // @version 1.1 // @namespace 1bae28cfed0eddb302b3ac9b578412a3 // @author Dan Garthwaite <dan@garthwaite.org> // @description Removes the cruft from the new zerohedge // @include http://*zerohedge.com/* // @run-at document-end // ==/UserScript== (function() { 'use strict'; var page = document.getElementById('page'); var sidebarLeft = document.getElementById('sidebar-left'); var sidebarRight = document.getElementById('sidebar-right'); page.style.maxWidth = "80em"; page.style.marginLeft = page.style.marginRight = "auto"; sidebarLeft.remove(); sidebarRight.remove(); var jk = function(a, inc) { if (!a.length) { return; } for (var i = 0; i < a.length; i++) { if (a[i].classList.contains('jk-current')) { var next = (i + inc) % a.length; a[i].classList.toggle('jk-current'); a[next].classList.toggle('jk-current'); break; } } }; /* Do jk navigation */ $('head').append('<style>.jk-current {outline: 1px solid navy;}</style>'); var arts = document.getElementsByTagName("article"); if (arts.length > 3) { arts[2].classList.add('jk-current'); jk(arts, 1); } $(document.body).keypress(function (event) { // ignore keypresses in input fields if (document.activeElement.tagName == 'INPUT') { return; } if (arts.length === 0) { return; } var key = String.fromCharCode(event.which).toUpperCase(); if (key === 'J' || key === ' ') { // J or space for next jk(arts, 1); } else if (key == 'K') { // K for back jk(arts, -1); } else if (key == 'O' || event.which == 13) { var toClick = $(".jk-current").find('a')[0]; console.log("toClick = " + toClick); toClick.click(); } else { return; } //scroll .jk-current to top of window $('html, body').animate({ scrollTop: $(".jk-current").offset().top - 100 }, 200); }); })();