-
Notifications
You must be signed in to change notification settings - Fork 0
/
极简b站.js
154 lines (146 loc) · 3.95 KB
/
极简b站.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// ==UserScript==
// @name 极简b站—bilibili
// @namespace http://tampermonkey.net/
// @version 1.2.4
// @description 极简b站是用来把b站伪装成文章 点击向前按钮可以来回切换 原始模式和伪装模式 灵感来源于 领导说我看视频不要被发现 如果有bug或想法邮箱联系我:[email protected]
// @author 向前 rational_stars
// @match *://*.bilibili.com/*
// @run-at document-end
// @grant none
// @license MIT
// @require https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.js
// ==/UserScript==
(function () {
var positionIcon = window.innerWidth;
var hiddenFlag = false; // 0隐藏 1显示
console.log("向前🇨🇳 ====> 极简b站—bilibili");
const documentArray = [
".bili-header",
".bili-header__bar",
".right-container",
".svg-icon",
".bpx-player-sending-bar",
".avatar",
'[title="投币(W)"]',
".sub-user-info",
".sub-reply-info",
".video-toolbar-right",
];
function hideElements() {
documentArray.forEach(function (item) {
$(item).hide();
});
}
function showElements() {
documentArray.forEach(function (item) {
$(item).show();
});
}
function is() {
if (hiddenFlag) {
showElements();
} else {
hideElements();
}
}
function resetDocumentStyles() {
const resetStyleArray = [
{
document: ".video-toolbar-container",
css: {
zIndex: "9999",
display: "flex",
position: "fixed",
left: positionIcon.right - 150 + "px",
top: "50%",
transform: "translateY(-50%)",
width: "150px",
},
},
{
document: ".video-toolbar-left",
css: {
flexWrap: "wrap",
height: "500px",
},
},
{
document: ".video-toolbar-container",
css: {
border: "none",
},
},
];
resetStyleArray.forEach(function (item) {
$(item.document).css(item.css);
});
}
function insertCustomDiv() {
let timeout;
const customDiv = $("<div>")
.addClass("rational-stars-btn")
.text("向前")
.css({
zIndex: "999999999",
position: "fixed",
backgroundColor: "skyblue",
right: 0,
top: "30%",
width: "60px",
height: "60px",
lineHeight: "60px",
transform: "translateX(50%)",
borderRadius: "50%",
textAlign: "center",
color: "#ffffff",
cursor: "pointer",
userSelect: "none",
})
.addClass("animate__animated")
.click(function () {
hiddenFlag = !hiddenFlag;
is();
})
.hover(
function () {
clearTimeout(timeout);
$(this)
.stop()
.css({
transform: "translateX(0)",
backgroundColor: "#fb7299",
})
.addClass("animate__lightSpeedInRight");
},
function () {
timeout = setTimeout(() => {
$(this)
.stop()
.css({
transform: "translateX(50%)",
backgroundColor: "skyblue",
})
.removeClass("animate__lightSpeedInRight")
}, 1000);
}
);
$("body").append(customDiv);
$("head").append($('<link rel="icon" href="https://cdn.jsdelivr.net/gh/rational-stars/picgo/favicon.ico">'));
$("body").append($(' <link href="https://cdn.bootcdn.net/ajax/libs/animate.css/4.1.1/animate.min.css" rel="stylesheet"></link>'));
}
window.onload = function () {
positionIcon = $(".video-container-v1").get(0).getBoundingClientRect();
// DOM 更新后重新插入插入元素
insertCustomDiv();
resetDocumentStyles();
is();
};
$(window).scroll(function () {
is();
$("video").each(function () {
if (!this.paused && !hiddenFlag) {
this.pause();
}
});
});
})();