-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinux.org.ru.js
108 lines (95 loc) · 2.94 KB
/
linux.org.ru.js
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// ==UserScript==
// @include https://www.linux.org.ru/*
// @name LOR correct pagePrev/Next
// @author Bga
// @version 0.1
// @description
// ==/UserScript==
opera.addEventListener('BeforeExternalScript', function(js) {
// opera.postError(js.element)
js.preventDefault()
}, false)
opera.addEventListener('BeforeScript', function(js) {
// opera.postError(js.element)
js.preventDefault()
}, false)
//# annoying [#comments] anchor.
if(location.hash == "#comments") {
//# set "#" instead, jumps to top
// location.hash = ""
location.replace(location.protocol + "//" + location.hostname + location.pathname + location.search)
}
!(function(global) {
var waitCommon = function(fn) {
if(global.Bga) {
fn()
}
else {
setTimeout(function() {
waitCommon(fn)
}, 0)
}
}
waitCommon(function() {
with(Bga) {
setProtoExpando()
document.documentElement.removeInlineEvents()
//# disable logging
var opera = { postError: function() { } }
var main = function(e) {
//# shrink ad img size
if(1) (function() {
document.querySelectorAll("img[src='/adv/qrator-box.png']").each(function(v) {
v.style.width = "200px"
})
})()
//# Alt+Left/Right jumps by comments, not by topics
if(1) {
var prevHref = xPath("//a[@class='page-number' and position() = 1]").each(function(v) {
opera.postError("prev " + v.href)
return v.href
})
var nextHref = xPath("//a[@class='page-number' and position() = count(../a)]").each(function(v) {
opera.postError("next " + v.href)
return v.href
})
var prevs = xPath("//*[@rel='prev' or @rel='Prev']")
if(prevs.length == 0) {
if(prevHref != null) {
document.head.appendChild(de("<link rel=prev href='" + prevHref + "'/>"))
}
}
else {
prevs.each(function(v) {
opera.postError("del " + v.href)
if(v.tagName == "LINK") {
v.href = prevHref
}
else {
v.removeAttribute("rel")
}
})
}
var nexts = xPath("//*[@rel='next' or @rel='Next']")
if(nexts.length == 0) {
if(nextHref != null) {
document.head.appendChild(de("<link rel=next href='" + nextHref + "'/>"))
}
}
else {
nexts.each(function(v) {
opera.postError("del " + v.href)
if(v.tagName == "LINK") {
v.href = nextHref
}
else {
v.removeAttribute("rel")
}
})
}
}
}
onDOMReady(main)
}
})
})(this)