Guest User

Untitled

a guest
Feb 16th, 2025
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.96 KB | None | 0 0
  1. Here is a Tampermonkey script I've used for some ime to make HN look the
  2. way I want it to (plain white background). It should be easy to adapt for
  3. a dark preference. It also adds a "bookmark" at the top of each page which
  4. is also easily removed if you don't want that.
  5.  
  6. - - cut here - - - - cut here - - - - cut here - - - - cut here - - - -
  7.  
  8.  
  9. // ==UserScript==
  10. // @name HN White
  11. // @namespace http://tampermonkey.net/
  12. // @version 0.1
  13. // @description Make HN background white
  14. // @author You
  15. // @match https://news.ycombinator.com/*
  16. // @grant none
  17. // ==/UserScript==
  18.  
  19. function wide(s) {
  20. document.querySelectorAll(s).forEach(e => {e.style.width = "95%"});
  21. }
  22.  
  23. function white(s) {
  24. document.querySelectorAll(s).forEach(e => {e.style.backgroundColor = "#FFFFFF"});
  25. }
  26.  
  27. function rm(s) {
  28. document.querySelectorAll(s).forEach(e => e.parentNode.removeChild(e));
  29. }
  30.  
  31. function bookmark() {
  32. var title_ = document.querySelectorAll(
  33. "#hnmain > tbody > tr > td > table.fatitem > tbody > tr > td.title > span.titleline > a"
  34. )[0].text
  35. var link_ = document.querySelectorAll(
  36. "#hnmain > tbody > tr > td > table.fatitem > tbody > tr > td.title > span.titleline > a"
  37. )[0].href
  38. var loc_ = document.location.href
  39. var d1 = (new Date()).toISOString().split('T')[0]
  40. var d2 = " /" + d1.substr(2, 2) + d1.substr(5, 2) + d1.substr(8, 2)
  41. document.querySelectorAll("body")[0].insertAdjacentHTML(
  42. "afterbegin","<pre>"+title_+" "+d2+"<br/> "+link_+"<br/> "+loc_+"</pre>"
  43. )
  44. document.querySelectorAll("head")[0].insertAdjacentHTML(
  45. "beforeend","<style>pre { max-width: none; }</style>"
  46. )
  47. }
  48.  
  49. (function() {
  50. 'use strict';
  51. wide("#hnmain");
  52. white("table");
  53. rm("#hnmain > tbody > tr:nth-child(1) > td > table > tbody > tr");
  54. rm("#hnmain > tbody > tr:nth-child(3) > td > table.fatitem > tbody > tr:nth-child(4) > td:nth-child(2) > form");
  55. bookmark();
  56. })();
  57.  
Advertisement
Add Comment
Please, Sign In to add comment