油猴脚本 调B站播放速度
作者:互联网
// ==UserScript== // @name New Userscript // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match *bilibili* // @include *bilibili* // @require https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js // @grant GM.getValue // @grant GM.setValue // @grant GM.listValues // @grant GM.deleteValue // @grant GM.openInTab // @grant GM.registerMenuCommand // @grant GM_unregisterMenuCommand // @grant GM_addStyle // @run-at document-idle // @grant unsafeWindow // ==/UserScript== function sleep(time) { console.log(`sleep被调用`,time) return new Promise((resolve) => setTimeout(resolve, time)); } (function() { 'use strict'; GM_addStyle(' .h-ol {position: absolute;top: 100px;left: 10px;z-index:9999 }'); let apiList = '<ul class="h-ol" id="my_wsh" ></ul>'; $(document.body).append(apiList); $('.h-ol').append(`<li> <input type="text" Style="width:24px" id="myratevalid" value="1"> </li>`); $('.h-ol').append(`<li><button type="button" id="myrate000">speed</button> </li>`); window.onload = function () { //方法内容 let mymap = []; function fds(node) { if (node.nodeType === 1) { // node.id = "id" + map_num.toLocaleString(); //给节点设置ID if (! mymap.includes(node.nodeName.toLocaleString(),0) ) { mymap.push(node.nodeName.toLocaleString()) } } //获取该元素节点的所有子节点 var children = node.childNodes; for (var i = 0; i < children.length; i++) { //递归调用 fds(children[i]); } } fds(document) // 用法 sleep(2500).then(() => { // 这里写sleep之后需要去做的事情 console.log(mymap) for (let j = 0; j < mymap.length; j++) { //递归调用 if(mymap[j].indexOf('VIDEO',0)!=-1){ console.log(`by_wsh看这里 myv=document.getElementsByTagName("`+mymap[j]+`")`) let myv_0=mymap[j] console.log(myv_0) // myv_0=document.getElementsByTagName(mymap[j])[0] document.getElementById("myrate000").addEventListener("click", function(){ console.log(`触发按钮事件`) let speed0=parseFloat(document.getElementById("myratevalid").value); document.getElementsByTagName(myv_0)[0].playbackRate=speed0 }); } } }) var e var box = document.getElementById("my_wsh"); //获取元素 var x, y; //鼠标相对与div左边,上边的偏移 var isDrop = false; //移动状态的判断鼠标按下才能移动 box.onmousedown = function (e) { e = e || window.event; //要用event这个对象来获取鼠标的位置 x = e.clientX - box.offsetLeft; y = e.clientY - box.offsetTop; isDrop = true; //设为true表示可以移动 } document.onmousemove = function (e) { //是否为可移动状态 if (isDrop) { e = e || window.event; var moveX = e.clientX - x; //得到距离左边移动距离 var moveY = e.clientY - y; //得到距离上边移动距离 //可移动最大距离 var maxX = document.documentElement.clientWidth - box.offsetWidth; var maxY = document.documentElement.clientHeight - box.offsetHeight; //范围限定 当移动的距离最小时取最大 移动的距离最大时取最小 //范围限定方法一 /*if(moveX < 0) { moveX = 0 } else if(moveX > maxX) { moveX = maxX; } if(moveY < 0) { moveY = 0; } else if(moveY > maxY) { moveY = maxY; } */ //范围限定方法二 moveX = Math.min(maxX, Math.max(0, moveX)); moveY = Math.min(maxY, Math.max(0, moveY)); box.style.left = moveX + "px"; box.style.top = moveY + "px"; } else { return; } } document.onmouseup = function () { isDrop = false; //设置为false不可移动 } } })();
标签:脚本,box,document,grant,var,mymap,GM,播放,油猴 来源: https://www.cnblogs.com/agfox123/p/16100111.html