Greasy Fork is available in English.
启用bilibili的html5播放器,自动宽屏、原生右键菜单
< Feedback on bilibili HTML5播放器
改了一下,添加了地址,注释掉了右键菜单部分。因为逼站的页面改了,番剧页面下该js失效,所以添加了番剧页面的地址,并把写法改了下,可对https页面生效:// @include *.bilibili.com/video/av*// @include *.bilibili.com/anime/*另外把右键菜单的部分给注释掉了……因为播放器的右键菜单有时候还有用,比如查看视频信息或者调整播放速度啥的。————————————希望原作者不会怪我贴在这里……可以直接复制粘贴下面的代码:————————————// ==UserScript==// @name bilibili HTML5播放器// @author nanavao// @namespace nana_vao_script// @description 启用bilibili的html5播放器,自动宽屏、原生右键菜单// @version 1.23// @include *.bilibili.com/video/av*// @include *.bilibili.com/anime/*// @run-at document-start// @grant GM_setValue// @grant GM_getValue// @grant GM_deleteValue// ==/UserScript=='use strict';(function () { let url = GM_getValue('url'); GM_deleteValue('url'); if (location.hostname == 'bangumi.bilibili.com') { if(url === location.href){ return; } GM_setValue('url', location.href); document.addEventListener('DOMContentLoaded', function () { window.stop(); location.href = document.querySelector('.v-av-link').href; }); } else { try{ localStorage.setItem('bilibililover', 'YESYESYES'); localStorage.setItem('defaulth5', '1'); }catch(e){} window.addEventListener('load', function () { this.$ = unsafeWindow.jQuery; $('.bilibili-player-video-btn-widescreen').click(); scrollToPlayer(); let intervalId = setInterval(function(){ if($('.bilibili-player-video-wrap video').length){ setContextMenuHandler(); clearInterval(intervalId); } },500); }); } function scrollToPlayer(){ var player = $('#bilibiliPlayer'); if($(window).scrollTop() === 0){ $(window).scrollTop(player.offset().top + player.height() - $(window).height()); } }/* 播放器右键菜单改浏览器菜单 function setContextMenuHandler(){ let contextMenuEvent = $._data( document.querySelector('.bilibili-player-video-wrap'), "events" ).contextmenu[0]; let oldHandler = contextMenuEvent.handler; let isElementClicked = function(ele, x, y){ let rect = ele.getBoundingClientRect(); return ((x > rect.left) && (x < rect.right) && (y > rect.top) && (y < rect.bottom)); }; let anyElementClicked = function(arr,x,y){ for(let i = 0;i < arr.length; i++){ if(isElementClicked(arr[i],x,y)){ return true; } } return false; }; let newHandler = function(e){ let eleArr = document.querySelectorAll('.bilibili-danmaku'); if(anyElementClicked(eleArr,e.clientX,e.clientY)){ oldHandler(e); } }; contextMenuEvent.handler = exportFunction(newHandler,contextMenuEvent); }*/}) ();
تسجيل الدخول إلى مرحلة ما بعد الرد.
改了一下,添加了地址,注释掉了右键菜单部分。
因为逼站的页面改了,番剧页面下该js失效,所以添加了番剧页面的地址,并把写法改了下,可对https页面生效:
// @include *.bilibili.com/video/av*
// @include *.bilibili.com/anime/*
另外把右键菜单的部分给注释掉了……因为播放器的右键菜单有时候还有用,比如查看视频信息或者调整播放速度啥的。
————————————
希望原作者不会怪我贴在这里……
可以直接复制粘贴下面的代码:
————————————
// ==UserScript==
// @name bilibili HTML5播放器
// @author nanavao
// @namespace nana_vao_script
// @description 启用bilibili的html5播放器,自动宽屏、原生右键菜单
// @version 1.23
// @include *.bilibili.com/video/av*
// @include *.bilibili.com/anime/*
// @run-at document-start
// @grant GM_setValue
// @grant GM_getValue
// @grant GM_deleteValue
// ==/UserScript==
'use strict';
(function () {
let url = GM_getValue('url');
GM_deleteValue('url');
if (location.hostname == 'bangumi.bilibili.com') {
if(url === location.href){
return;
}
GM_setValue('url', location.href);
document.addEventListener('DOMContentLoaded', function () {
window.stop();
location.href = document.querySelector('.v-av-link').href;
});
} else {
try{
localStorage.setItem('bilibililover', 'YESYESYES');
localStorage.setItem('defaulth5', '1');
}catch(e){}
window.addEventListener('load', function () {
this.$ = unsafeWindow.jQuery;
$('.bilibili-player-video-btn-widescreen').click();
scrollToPlayer();
let intervalId = setInterval(function(){
if($('.bilibili-player-video-wrap video').length){
setContextMenuHandler();
clearInterval(intervalId);
}
},500);
});
}
function scrollToPlayer(){
var player = $('#bilibiliPlayer');
if($(window).scrollTop() === 0){
$(window).scrollTop(player.offset().top + player.height() - $(window).height());
}
}
/* 播放器右键菜单改浏览器菜单
function setContextMenuHandler(){
let contextMenuEvent = $._data( document.querySelector('.bilibili-player-video-wrap'), "events" ).contextmenu[0];
let oldHandler = contextMenuEvent.handler;
let isElementClicked = function(ele, x, y){
let rect = ele.getBoundingClientRect();
return ((x > rect.left) && (x < rect.right) && (y > rect.top) && (y < rect.bottom));
};
let anyElementClicked = function(arr,x,y){
for(let i = 0;i < arr.length; i++){
if(isElementClicked(arr[i],x,y)){
return true;
}
}
return false;
};
let newHandler = function(e){
let eleArr = document.querySelectorAll('.bilibili-danmaku');
if(anyElementClicked(eleArr,e.clientX,e.clientY)){
oldHandler(e);
}
};
contextMenuEvent.handler = exportFunction(newHandler,contextMenuEvent);
}
*/
}) ();