// ==UserScript==
// @name bili_fix_player
// @namespace bili
// @description 修复B站播放器,黑科技,列表页、搜索页弹窗,破乐视限制,提供高清、低清晰源下载,弹幕下载
// @include /^.*\.bilibili\.tv\/(video\/|search)?.*$/
// @include /^.*bilibili\.kankanews\.com\/(video\/|search)?.*$/
// @version 3.5.2
// @grant GM_xmlhttpRequest
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_addStyle
// @author 绯色
// @downloadURL none
// ==/UserScript==
/**
出现无法播放情况先关闭自动修复
2013-12-14修复B站播放器无法在火狐魔镜弹窗播放
2014-01-23替换优酷、爱奇艺、搜狐为B站播放器
2014-03-28增加下载视频按钮
2014-05-10收益于自己的B站追番计划(http://v.myacg.ga或者http://weiyun.jd-app.com),代码逻辑重构(不再区分视频源再解析视频),并重写UI
2014-05-10受诸多基佬要求,增加除首页外其他分类页面的弹窗播放(初衷是为了弹窗乐视源)
2014-05-11还是基佬要求,增加弹窗播放器分P效果,增加弹幕下载功能,在吧友大神田生的建议下,正则表达式加强匹配
2014-05-13增加搜索页面的弹窗播放,并且支持多P和显示当前P,增加模糊画质下载按钮
2014-05-14增加首页弹窗播放,基本实现全站可弹窗(首页新番专题列表除外等)
2014-05-25感谢吧友lzgptdgj提供BUG,在小型播放器下,屏蔽规则会无效的问题,已经修复
------------以下信息提供给开发者-----------
//https://static-s.bilibili.tv/play.swf---新版播放器
//http://static.hdslb.com/play.swf---旧版播放器
//https://static-s.bilibili.tv/play_old.swf---考古级别播放器
-------------------------------------------
*/
(function (){
//初始化 init
if (GM_getValue('auto') == undefined) GM_setValue('auto', 1);
if (GM_getValue('player_size') == undefined) GM_setValue('player_size', 1);
//初始化jquery支持
var $=unsafeWindow.$;
/**
-------------------------------用户界面GUI View-------------------------------------
*/
//函数,插入可视化操作视图
function insert_html(type) {
var auto= GM_getValue('auto') ? '已打开' : '已关闭';
var player_size= GM_getValue('player_size') ? '大型' : '小型';
var div = '脚本(`・ω・´)\
\
+10086';
$('div.num:nth-child(4) > ul:nth-child(1) > li:nth-child(1)').html(div);
var css = '.btn{font-size: 12px;height: 25.6px;line-height: 25.6px;padding: 0px 2px;transition-property: #000, color;\
transition-duration: 0.3s;\
box-shadow: none;\
color: #FFF;\
text-shadow: none;\
border: medium none;\
background: none repeat scroll 0% 0% #00A1CB!important;}\
.btn.active{\
background: none repeat scroll 0% 0% #F489AD!important;}\
.btn.notice{\
background-color:#A300C0!important;}\
.font{\
font-size:11px!important;}\
';
GM_addStyle(css);
//监听修复按钮
var btn = document.querySelector("#bili_fix");
btn.addEventListener("click", set_auto, false);
//监听播放器大小按钮
var btn = document.querySelector("#player_size");
btn.addEventListener("click", set_player, false);
}
//函数,插入下载按钮
function insert_download_button(url, count) {
$('#av_source').append('分段【' + count + '】');
}
//设置参数
//修复按钮事件
function set_auto() {
GM_getValue('auto') ? GM_setValue('auto', 0) : GM_setValue('auto', 1);
var s = GM_getValue('auto') ? '已打开' : '已关闭';
document.getElementById('bili_fix').innerHTML = s;
$("#bili_fix").toggleClass("active");
$('#bili_set_status').html('已更改,刷新生效_(:3」∠)_');
}
//播放器大小按钮事件
function set_player() {
GM_getValue('player_size') ? GM_setValue('player_size', 0) : GM_setValue('player_size', 1);
var s = GM_getValue('player_size') ? '大型' : '小型';
document.getElementById('player_size').innerHTML = s;
$("#player_size").toggleClass("active");
$('#bili_set_status').html('已更改,刷新生效_(:3」∠)_');
}
/**
-------------------------------函数 Model-------------------------------------
*/
//函数,替换播放器
function Replace_player(aid, cid) {
if (GM_getValue('auto') == '1') {
if (GM_getValue('player_size') == '1') {
document.getElementById('bofqi').innerHTML = ' ';
}else{
document.getElementById('bofqi').outerHTML = '