-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpikabu.ru.js
More file actions
94 lines (77 loc) · 3.26 KB
/
pikabu.ru.js
File metadata and controls
94 lines (77 loc) · 3.26 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
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
// ==UserScript==
// @name twitter
// @include https://pikabu.ru/*
// @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)
!(function(global) {
var waitCommon = function(fn) {
if(global.Bga) {
fn()
}
else {
setTimeout(function() {
waitCommon(fn)
}, 0)
}
}
waitCommon(function() {
with(Bga) {
onDOMReady(function() {
setProtoExpando()
document.documentElement.removeInlineEvents()
var log = 1 ? logRaw : logNull
//# lazy imgs to real
document.getElementsByTagName("IMG").each(function(img) {
if(img.getAttribute("data-src") != null) {
img.src = img.getAttribute("data-src")
}
else {
}
})
//# show video
if(1) (function() {
var replaceExt = function(path, newExt) {
var pathWithoutExt = path.slice(0, path.indexOf(".", path.lastIndexOf("/")) >>> 0)
return pathWithoutExt + newExt
}
assert.eq(replaceExt("test.jpg", ".png"), "test.png")
assert.eq(replaceExt("/test", ".png"), "/test.png")
document.getElementsByClassName("player").each(function(player) {
var src = player.getAttribute("data-source")
if(src.match(".youtube.com/")) {
player.replace(de("".concat("<iframe src='", src, "' width='", player.getAttribute("data-width"), "' height='", player.getAttribute("data-height"), "'>")))
}
else {
src = replaceExt(src, ".mp4")
log("embed1")
var w = 640
var h = 480
var volume = 0
var videoDom = de("".concat('<embed src="', src, '" autostart="false" showcontrols="true" showstatusbar="1" type="application/x-mplayer2" bgcolor="white" style="width: ', w, 'px; height: ', h, 'px" volume="', volume, '">'))
if(0) {
var videoDom = de("".concat("<video controls width='", player.getAttribute("data-width"), "' height='", player.getAttribute("data-width"), "'/>"))
if(player.getAttribute("data-size-webm")) {
videoDom.appendChild(de("".concat("<source src='", replaceExt(src, ".webm"), "' type=video/webm />")))
}
if(player.getAttribute("data-size-mp4")) {
videoDom.appendChild(de("".concat("<source src='", replaceExt(src, ".mp4"), "' type=video/mp4 />")))
}
videoDom.appendChild(de("".concat("<source src='", replaceExt(src, ".mp4"), "' type=video/mp4 />")))
videoDom.appendChild(de("".concat("<source src='", replaceExt(src, ".webm"), "' type=video/webm />")))
}
player.replace(videoDom)
}
})
})()
})
}
})
})(this)