Last active
November 13, 2024 21:19
-
-
Save ernstki/10ae021f62ef32ccf2bed089d0ecc3fc to your computer and use it in GitHub Desktop.
A userscript for adding link rel='next' to the head of the perl.org NNTP browser
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 Add link rel=next for "Thread Next" links | |
// @namespace https://github.com/ernstki | |
// @version 2024-11-13 | |
// @description For use with https://gitlab.com/arty.name/firefox-extension-find-next-page or similar | |
// @author Kevin Ernst (ernstki -at- mail.uc.edu) | |
// @match https://www.nntp.perl.org/* | |
// @icon https://icons.duckduckgo.com/ip4/perl.org.ico | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
var link, head, haveLinkRel = false; | |
Array.prototype.forEach.call(document.getElementsByTagName('a'), e => { | |
if (e.textContent == 'Thread Next') { | |
if (haveLinkRel) return; | |
link = document.createElement('link'); | |
head = document.getElementsByTagName('head')[0]; | |
link.setAttribute('rel', 'next'); | |
link.setAttribute('href', e.getAttribute('href')); | |
head.appendChild(link); | |
haveLinkRel = true; | |
} | |
}); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment