1
0
Fork 0
mirror of https://github.com/Phantop/dotfiles synced 2024-11-29 01:52:57 +00:00
dotfiles/.local/share/qutebrowser/greasemonkey/ao3lz.js

25 lines
949 B
JavaScript
Raw Normal View History

// ==UserScript==
// @name AO3 Lazier
// @namespace ao3lazier
// @description Adds a latest chapter button to the top navigation.
// @include http*://archiveofourown.org/*
// ==/UserScript==
var match = location.pathname.match(/^(\/works\/\d+\/chapters\/)\d+/);
if (match) {
var chapEls = document.getElementById('selected_id').children;
var lastChapEl = chapEls[chapEls.length-1];
if (!lastChapEl.selected) {
var lastChap = lastChapEl.value;
var button = document.createElement('a');
button.href = match[1] + lastChap;
button.appendChild(document.createTextNode('Latest Chapter ' + String.fromCharCode(0x2192)));
var buttonParent = document.createElement('li');
buttonParent.className = 'chapter';
buttonParent.appendChild(button);
var chapsParent = document.getElementById('chapter_index').parentElement;
chapsParent.parentElement.insertBefore(buttonParent, chapsParent);
}
}