Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Here is a Tampermonkey script I've used for some ime to make HN look the
- way I want it to (plain white background). It should be easy to adapt for
- a dark preference. It also adds a "bookmark" at the top of each page which
- is also easily removed if you don't want that.
- - - cut here - - - - cut here - - - - cut here - - - - cut here - - - -
- // ==UserScript==
- // @name HN White
- // @namespace http://tampermonkey.net/
- // @version 0.1
- // @description Make HN background white
- // @author You
- // @match https://news.ycombinator.com/*
- // @grant none
- // ==/UserScript==
- function wide(s) {
- document.querySelectorAll(s).forEach(e => {e.style.width = "95%"});
- }
- function white(s) {
- document.querySelectorAll(s).forEach(e => {e.style.backgroundColor = "#FFFFFF"});
- }
- function rm(s) {
- document.querySelectorAll(s).forEach(e => e.parentNode.removeChild(e));
- }
- function bookmark() {
- var title_ = document.querySelectorAll(
- "#hnmain > tbody > tr > td > table.fatitem > tbody > tr > td.title > span.titleline > a"
- )[0].text
- var link_ = document.querySelectorAll(
- "#hnmain > tbody > tr > td > table.fatitem > tbody > tr > td.title > span.titleline > a"
- )[0].href
- var loc_ = document.location.href
- var d1 = (new Date()).toISOString().split('T')[0]
- var d2 = " /" + d1.substr(2, 2) + d1.substr(5, 2) + d1.substr(8, 2)
- document.querySelectorAll("body")[0].insertAdjacentHTML(
- "afterbegin","<pre>"+title_+" "+d2+"<br/> "+link_+"<br/> "+loc_+"</pre>"
- )
- document.querySelectorAll("head")[0].insertAdjacentHTML(
- "beforeend","<style>pre { max-width: none; }</style>"
- )
- }
- (function() {
- 'use strict';
- wide("#hnmain");
- white("table");
- rm("#hnmain > tbody > tr:nth-child(1) > td > table > tbody > tr");
- rm("#hnmain > tbody > tr:nth-child(3) > td > table.fatitem > tbody > tr:nth-child(4) > td:nth-child(2) > form");
- bookmark();
- })();
Advertisement
Add Comment
Please, Sign In to add comment