// ==UserScript==
// @name 超好用的哔哩哔哩可自定义倍速+可拖动以调整位置+具有记忆位置功能(网页刷新后仍在上次调整后的相同位置),最高可达到5倍速,且解决了网站里点击除视频外的其他地方后无法用方向键和空格键调控视频播放的问题)
// @namespace http://tampermonkey.net/
// @version 4.1.0
// @description 超好用的哔哩哔哩可自定义倍速和自行拖动调整位置播放条/菜单栏(倍速播放条可通过自行拖拽调整位置且有位置记忆功能,最高可达到5倍速,且解决了网站里点击除视频外的其他地方后无法用方向键和空格键调控视频播放的问题2)
// @author 薪炎,拔剑!
// @match https://www.bilibili.com/video/*
// @icon https://www.google.com/s2/favicons?domain=bilibili.com
// @grant unsafeWindow
// @require https://code.jquery.com/jquery-3.6.0.min.js
// ==/UserScript==
(function() {
'use strict';
//$("body").on("click",function(){var timer=setTimeout(function(){$(".bilibili-player-video-info").click();},50);});
$(function(){
console.log($(".bui-collapse-arrow-text"));
// $("body").prepend("<div id=rate><div>");
// $(".bui-collapse-arrow").append("<div id=rate><div>");
//$("#viewbox_report").prepend("<div id=rate><div>");
var time=setInterval(function(){
if($(".bui-collapse .bui-collapse-header .bui-collapse-arrow").css("right")=="14px"){
$(".bui-collapse .bui-collapse-header .bui-collapse-arrow").css({right:"170px"});
console.log("change");
clearInterval(time);
}
},1);
$("body").prepend("<div id=rate><div>");
$("#rate").css({
overflow:"hidden",
position:"absolute",
//right:"393px",
//top:"160px",
left:"700px",
top:"158px",
width:"200px",
height:"33px",
borderRadius:"9px",
textAlign:"center",
backgroundColor:"#b2bec3",
zIndex:"2147483647"
});
firstIn();
$("#rate").prepend("<button class='rateitem'>4</button>");$("#rate").prepend("<button class='rateitem'>3</button>");
$("#rate").prepend("<button class='rateitem'>2.5</button>");$("#rate").prepend("<button class='rateitem'>2</button>");
$("#rate").prepend("<button class='rateitem'>1.5</button>");$("#rate").prepend("<button class='rateitem'>1.25</button>");
$("#rate").prepend("<button class='rateitem'>1</button>");$("#rate").prepend("<button class='rateitem'>0.85</button>");
$(".rateitem").css({
width:"25px",
height:"33px",
lineHeight:"33px",
outline:"none",
border:"none",
fontWeight:"bold",
backgroundColor:"#b2bec3",
});
$("#rate button").on("mouseover",function(){
$(this).css({
backgroundColor:"#dfe6e9"
});
});
$("#rate button").on("mouseout",function(){
$(this).css({
backgroundColor:"#b2bec3"
});
});
$("#rate button").on("mousedown",function(){
$(this).css({
backgroundColor:"#d1d8e0"
});
});
$("#rate button").on("mouseup",function(){
$(this).css({
backgroundColor:"#dfe6e9"
});
});
$("#rate button").on("click",function(){
console.log($(this).text());
$($(".bpx-player-ctrl-playbackrate-menu").children()[3]).attr('data-value',($(this).text()))
console.log($($(".bpx-player-ctrl-playbackrate-menu").children()[3]).attr('data-value'),123)
$($(".bpx-player-ctrl-playbackrate-menu").children()[3]).click()
var timer1=setTimeout(function(){clearTimeout(timer1);$(".bilibili-player-video-info").click();return;},50);
});
function move(e){
var x=e.pageX-$("#rate").offset().left;
var y=e.pageY-$("#rate").offset().top;
$("#rate").on("mousemove",function(e){
// console.log(e.pageX,e.pageY);
$("#rate").css({
top:e.pageY-y,
left:e.pageX-x
});
});
}
function cancelMove(){
$("#rate").off("mousemove");
}
$("#rate").on("mousedown","button",move);
$("#rate").on("mouseup","button",cancelMove);
function firstIn(){
var p={x:$("#rate").css("left"),y:$("#rate").css("top")};
if(localStorage.getItem("ratePosition")==null){
console.log("Can't find default position!");
console.log("position now is "+ p);
localStorage.setItem("ratePosition",JSON.stringify(p));
console.log("setItem complete..");
}
else{
console.log("Find local positional data!");
$("#rate").css({
left:getxy().x,
top:getxy().y
})
}
}
function getxy(){
return JSON.parse(localStorage.getItem("ratePosition"));
}
function recordxy(){
var p=getxy();
console.log("up and record");
p.x=$("#rate").css("left");
p.y=$("#rate").css("top");
console.log(p.x,p.y);
localStorage.setItem("ratePosition",JSON.stringify(p));
}
$("#rate").on("mouseup","button",recordxy);
});
// Your code here...
})();