-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbilibili时间跳转.js
52 lines (44 loc) · 1.59 KB
/
bilibili时间跳转.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
// ==UserScript==
// @name bilibili时间跳转
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.bilibili.com/video/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant none
// ==/UserScript==
setTimeout(() => {
add_container()
add_input()
}, 3000);
function add_input() {
var inp = document.createElement("input");
// inp.type = "number";//不能显示字符串
//传入点击按钮的value值到新的按钮
inp.value = '参考格式00:00:00';
inp.style.fontSize = "20px"//fontsize没大写
inp.onchange = function () {
data_string = "0 " + inp.value
new_time = (new Date(data_string).getTime() - new Date("0 00:00:00").getTime()) / 1000
// document.querySelector("a[data-video-time]").setAttribute("data-video-time", new_time)
// document.querySelector("a[data-video-time]").click()
document.querySelector("div.bpx-player-video-perch > div > video").currentTime = new_time
}
var contain_ = document.querySelector("#sp-ac-container")
contain_.appendChild(inp);
//传入点击按钮的id到新的按钮(传入是id+1防止重复)
// inp.id = id;
//当方法有参数时,用onclick = 方法名(参数)时就有错了,需要在方法名前面加function()
// inp.onclick = function() {
// b1(id);
// };
}
function add_container() {
let Container = document.createElement('div');
Container.id = "sp-ac-container";
Container.style.position = "fixed";
Container.style.right = "0px";
Container.style.top = "80px";
document.body.appendChild(Container);
}