Last active
July 6, 2023 12:20
-
-
Save ArthurKun21/ee9511d4373c0c9c92e2d0fa6c46fada to your computer and use it in GitHub Desktop.
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 Hacker News Open Links in New Tab | |
// @namespace http://tampermonkey.net/ | |
// @version 1.1 | |
// @description Open links on Hacker News in a new tab | |
// @license GPL v3.0 | |
// @author xdpirate | |
// @match https://news.ycombinator.com/* | |
// @icon https://www.google.com/s2/favicons?sz=64&domain=ycombinator.com | |
// @grant none | |
// ==/UserScript== | |
let links = document.querySelectorAll("td.title > span.titleline > a"); | |
for(let i = 0; i < links.length; i++) { | |
links[i].target = "_blank"; | |
} | |
let commentlinks = document.querySelectorAll("td.subtext > span.subline > a"); | |
for(let i = 0; i < commentlinks.length; i++) { | |
//console.log(commentlinks[i].href); | |
if(commentlinks[i].href.startsWith("https://news.ycombinator.com/item?id=")) { | |
commentlinks[i].target = "_blank"; | |
} | |
} | |
(function() { | |
'use strict'; | |
// Get all links within comments | |
let commentLinks = document.querySelectorAll('.comment a'); | |
// Loop through each link and set the target attribute to "_blank" | |
commentLinks.forEach(link => { | |
link.setAttribute('target', '_blank'); | |
}); | |
})(); | |
var styles = ` | |
* { | |
font-size: 102% !important; | |
font-family: Calibri; | |
} | |
` | |
// Fixes font size to be 100% of normal size, instead of being smaller | |
// and hurting my eyes... | |
var ss = document.createElement("style"); | |
ss.innerHTML = styles; | |
document.head.appendChild(ss); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment