-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathpagerize_ars_technica.user.js
More file actions
55 lines (49 loc) · 2.17 KB
/
Copy pathpagerize_ars_technica.user.js
File metadata and controls
55 lines (49 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// ==UserScript==
// @name Pagerize Ars Technica
// @description Mark up Ars Technica with pager metadata
// @author chocolateboy
// @copyright chocolateboy
// @version 0.6.3
// @namespace https://github.com/chocolateboy/userscripts
// @license GPL: https://www.gnu.org/copyleft/gpl.html
// @include http://arstechnica.com/*
// @include http://*.arstechnica.com/*
// @include https://arstechnica.com/*
// @include https://*.arstechnica.com/*
// @require https://code.jquery.com/jquery-3.5.1.slim.min.js
// @require https://cdn.jsdelivr.net/gh/chocolateboy/jquery-pagerizer@v1.0.0/dist/pagerizer.min.js
// @grant GM_log
// ==/UserScript==
// XXX note: the unused grant is a workaround for a Greasemonkey bug:
// https://github.com/greasemonkey/greasemonkey/issues/1614
/*
https://arstechnica.com/information-technology/2010/01/video-editing-in-linux-a-look-at-pitivi-and-kdenlive/2/
<nav class="page-numbers">
Page:
<span class="numbers">
<a href="video-editing-in-linux-a-look-at-pitivi-and-kdenlive/">1</a>
2
<a href="video-editing-in-linux-a-look-at-pitivi-and-kdenlive/3">3</a>
<a href="video-editing-in-linux-a-look-at-pitivi-and-kdenlive/4">4</a>
<a href="video-editing-in-linux-a-look-at-pitivi-and-kdenlive/3">
<span class="next">Next <span class="arrow">→</span></span>
</a>
</span>
</nav>
*/
var $navbar = $('nav.page-numbers span.numbers');
var $pageNumber = $navbar.contents().filter(function () {
return this.nodeType === 3 && $.trim(this.nodeValue).match(/^\d+$/)
});
if ($pageNumber.prev().length) {
// remove the rel from the "Previous Story" link
$('a[rel="prev"], a[rel="previous"]').removeRel('prev', 'previous');
// use "previous" rather than "prev" (or both) to work around a bug in Vimperator:
// https://github.com/vimperator/vimperator-labs/pull/570
$pageNumber.prev().addRel('previous');
}
if ($pageNumber.next().length) {
// remove the rel from the "Next Story" link
$('a[rel="next"]').removeRel('next');
$pageNumber.next().addRel('next');
}