bilibili登录页面代码html5,bilibili HTML5播放器

// ==UserScript==

// @name bilibili HTML5播放器

// @author nanavao

// @namespace nana_vao_script

// @description 启用bilibili的html5播放器,自动宽屏、原生右键菜单

// @version 1.23

// @include http://www.bilibili.com/video/av*

// @include http://bangumi.bilibili.com/anime/v/*

// @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);

}

}) ();

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值