NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name B战视频在线观看人数 // @namespace http://tampermonkey.net/ // @version 2024-05-27 // @description 添加一个跳转在线播放视频的按钮 // @author Kirari // @match https://www.bilibili.com/ // @license MIT // @icon https://www.google.com/s2/favicons?sz=64&domain=openuserjs.org // @grant none // ==/UserScript== (function() { 'use strict'; var url = [ "https://www.bilibili.com/video/online.html", "https://www.bilibili.com/video/online.html?spm_id_from=333.851.b_7265706f7274466972737432.14" ]; var randomIndex = Math.floor(Math.random() * url.length); var randomUrl = url[randomIndex]; var newDiv = document.createElement("div"); newDiv.id = "online_button_container"; var newButton = document.createElement("button"); newButton.textContent = "在线人数"; newButton.onclick = function() { window.location.href = randomUrl; }; newDiv.appendChild(newButton); var browserWidth = window.innerWidth; newDiv.style.position = 'sticky'; newDiv.style.bottom = '30px'; newDiv.style.left = browserWidth-100+'px'; newDiv.style.zIndex = '1000'; newDiv.style.width='70px'; newDiv.style.border = 'solid 1px black'; newDiv.style.borderRadius = '25px'; var parentElement = document.body; parentElement.appendChild(newDiv); var style = document.createElement('style'); style.innerHTML = ` @media (max-width: 600px) { #online_button_container { bottom: 5px; right: 5px; } #online_button_container button { font-size: 14px; padding: 10px; } } @media (min-width: 601px) { #online_button_container { bottom: 10px; right: 10px; } #online_button_container button { font-size: 16px; padding: 12px; } } `; document.head.appendChild(style); // Your code here... })();