{}
let timeEnd = console.timeEnd
timeEnd = ()=>{}
log('------start------')
console.time('main')
requestAnimationFrame(()=>true)
let [infos, lists_length, cids] = init_infos()
// log(infos.dms, infos.views, cids)
load_视频选集_dms()
function ready_data_count() { return Object.values(infos.dms).filter(v => typeof v === 'number' && v >= 0).length }
// function insert_data_count() { return Object.values(infos.dms).filter(v => typeof v === 'number' && v < 0).length }
function unxhr_data_count() { return Object.values(infos.dms).filter(v => v === undefined).length }
function xhr_err_data_count() { return Object.values(infos.dms).filter(v => typeof v === 'string').length }
//加载
log('数据共:', lists_length)
waitForTrue(()=>{
let ready_count = ready_data_count()
log('已读取:', ready_count)
//加载完成
if(ready_count === lists_length) { log('OK 加载完成:', ready_count); timeEnd('main'); console.time('main2'); return true }
//如果还有未加载数据,继续等待读取
let unxhr_count = unxhr_data_count()
if(unxhr_count > 0) { log('还有未加载数据:', unxhr_count, ',继续'); return false }
//上一轮加载循环完成,重新加载错误数据
let xhr_err_count = xhr_err_data_count()
if(xhr_err_count > 0) { log('上一轮加载循环完成,重新加载错误数据:', 'xhr_err_count'); load_视频选集_dms(); return false }
return false
}, ()=>{
//插入$episode(view / dm)
set_episode()
//test
// function head_test(){
// $('.clickitem').add('.video-episode-card__info').each((i,v)=>{
// $(v).prepend($(``))
// })
// }
// head_test()
// 动态调整宽度,保证播放数和弹幕数等正常显示,超出宽度退出
waitForNode(()=>{
if(video_type === '视频选集') return true
if($('.base-video-sections-v1').width() > 600) { err('hhh_episode_view宽度调整错误'); return true }
let height_limit = 16
let $episode = $('.hhh_episode_view')
for(let i=0; i<$episode.length; i++){
if($episode.get(i).clientHeight > height_limit){
$('.base-video-sections-v1').width( $('.base-video-sections-v1').width() + 50 )
return false
}
}
return true
}, ()=>{
let header_column_names = video_type === '合集' ? ['重置', 'Title', 'View', 'DM', 'TM'] : ['重置', 'Title', 'DM', 'TM']
//加入排序HEAD
function add_listsort(){
if($('.hhh_episode_view').length <= 0) return
//Sort Head CSS
$('#hhh_style_listsort').remove()
if($('#hhh_style_listsort').length <= 0){
append_style($('.video-sections-head').add('.head-con'), 'hhh_style_listsort',
`
.hhh-listsort-head {
background-repeat: no-repeat;
background-position: center right;
padding: 4px 0px 4px 0px;
white-space: normal;
cursor: pointer;
border: 1px solid #cdcdcd;
border-right-width: 0px;
background-color: #99bfe6; /*#99bfe6*/
background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
font-weight: bold;
text-shadow: 0 1px 0 rgb(204 204 204 / 70%);
opacity: 0.7;
user-select: none;
white-space: pre;
/*background-color: #9fbfdf;*/
/*background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7); ascending*/
/*background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7); descending*/
}
.hhh-listsort-head-asc {
/*opacity: 0.91;*/
background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
}
.hhh-listsort-head-desc {
/*opacity: 0.91;*/
background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
}
`
)
}
function get_header_item_width(video_type){
function get_items_left_edge($items){
let left_edges = []
$items.each((i,v)=>{ left_edges.push(v.getBoundingClientRect().x) })
return Math.min(...left_edges)
}
let reset = $('.video-episode-card__info:first').add('.list-box li:first')[0].getBoundingClientRect().x
let title = reset + 32
let view = get_items_left_edge($('.hhh_episode_view .view')) + 2
let dm = get_items_left_edge($('.hhh_episode_view .dm')) + 2
let duration = get_items_left_edge($('.base-video-sections-v1 .video-episode-card__info-duration').add('.cur-list .duration')) - 2
let end = reset + $('.video-episode-card__info:first').add('.list-box li:first')[0].getBoundingClientRect().width
if(duration - dm < 38) dm -= 38 - (duration - dm) // 保持header完整显示最低宽度
if(video_type === '合集') return [reset, title, view, dm, duration, end].map((v,i,arr)=>arr[i+1]-v).slice(0, -1)
if(video_type === '视频选集') return [reset, title, dm, duration, end].map((v,i,arr)=>arr[i+1]-v).slice(0, -1)
}
let total_w = $('.video-episode-card__info:first').add('.list-box li:first')[0].getBoundingClientRect().width
let margin_left = $('.video-episode-card__info:first').add('.list-box li:first')[0].getBoundingClientRect().x
- $('.video-sections-head:first').add('.head-right:first')[0].getBoundingClientRect().x
let margin_top, margin_bottom
if(video_type === '合集'){
margin_top = 0, margin_bottom = 1
}else if(video_type === '视频选集'){
$('.list-box .link-content').width(260)
margin_top = 10, margin_bottom = 1
}
let widths = get_header_item_width(video_type)
// log(widths)
// let [Index, Title, View, DM, TM] = ['重置', 'Title', 'View', 'DM', 'TM']
$('#hhh_listsort').remove()
$('.border-bottom-line:first').add('.head-right').before(`
${(function add_span(){
let spans = ''
widths.forEach((v,i)=>{ spans += ` ${header_column_names[i]}` })
return spans
})()}
`)
$('#hhh_listsort span:first').css({'background-image': 'none'})
$('#hhh_listsort span:last ').css({'border-right-width': '1px'})
}
//修改bilibili setSize函数,修改对应语句,重置right-container宽度,适配插入的节点listsort(主要是点击量和弹幕量)
function reset_setSize(){
//n = 1680 < innerWidth ? 411 : 350
let reg = /(n\s*=\s*\d+\s*<\s*innerWidth\s*\?\s*)(\d+)\s*:\s*(\d+)/
let new_w = $('.base-video-sections-v1').width() + 50
window.setSize = eval(`(${window.setSize.toString().replace(reg, `$1${new_w}:${new_w}`)})`)
window.dispatchEvent(new Event('resize'))
}
//宽屏模式保持video屏幕在正中
function keep_video_centered(){
if($('#hhh_listsort')[0]?.hhh_video_container_width === undefined){
let reg = /(n\s*=\s*\d+\s*<\s*innerWidth\s*\?\s*)(\d+)\s*:\s*(\d+)/
let r = window.setSize.toString().match(reg)
$('#hhh_listsort')[0].hhh_video_container_width = r[2]
$('.bpx-player-container')[0].addEventListener('DOMSubtreeModified', function fn_() {
//n = 1680 < innerWidth ? 411 : 350
let r = window.setSize.toString().match(reg)
if($(this).attr('data-screen') === 'wide' && r[2] !== '411'){
// console.log($(this).attr('data-screen'), r[2], r[3])
window.setSize = eval(`(${window.setSize.toString().replace(reg, `$1${411}:${350}`)})`)
window.dispatchEvent(new Event('resize'))
}
if($(this).attr('data-screen') !== 'wide' && r[2] === '411'){
// console.log($(this).attr('data-screen'), r[2], r[3])
let w = $('#hhh_listsort')[0].hhh_video_container_width
window.setSize = eval(`(${window.setSize.toString().replace(reg, `$1${w}:${w}`)})`)
window.dispatchEvent(new Event('resize'))
}
})
}
}
function header_sort(){
//['重置', 'Title', 'View', 'DM', 'TM', 'TM_str', 'View_fmt', 'DM_fmt'] ...
//【listsort】事件
//video-section-list section-0 section-1 section-2 ...
function store(i){
let $video_list = $(`.video-section-list:eq(${i})`)
let $video_cards = $video_list.find('.video-episode-card').add('.list-box li')
let video_cards_array = Array.from($video_cards)
return video_cards_array
}
function restore(new_sort_arr, sort_arr, video_cards_array, i){
//建立排序后和真实顺序的对应关系,范围:1~length
let real_to_draw = []
new_sort_arr.forEach(function(v,i){
real_to_draw[v[0]] = i+1
})
let new_video_cards_array = []
sort_arr.forEach(function(v,i){
new_video_cards_array[real_to_draw[v[0]]-1] = video_cards_array[i]
})
let video_list = $('.video-section-list')[`${i}`] || $('.list-box')[0]
video_list.innerHTML = ''
new_video_cards_array.forEach(function(v,i){
video_list.appendChild(v)
})
}
function bulid_sort_arr(cards){
let unsorted_data_arr = []
$(cards).each((i,v)=>{
let $v = $(v)
let Title = $v?.find('.video-episode-card__info-title')?.attr('title') || $v?.find('.link-content')?.text()
let TM = timestr_to_second($v?.find('.video-episode-card__info-duration').add($v?.find('.duration'))?.text())
let $episode = $v.find('.hhh_episode_view')
let [real_idx, View, DM] = [+$episode.attr('real_idx'), +$episode.attr('view'), +$episode.attr('dm')]
// log(real_idx, Title, View, DM, TM)
// '合集' ? ['重置', 'Title', 'View', 'DM', 'TM'] : ['重置', 'Title', 'DM', 'TM']
let unsorted_data_columns = header_column_names.map((name)=>{
return name === '重置' && real_idx ||
name === 'Title' && Title ||
name === 'View' && View ||
name === 'DM' && DM ||
name === 'TM' && TM
})
// log(header_column_names, unsorted_data_columns)
unsorted_data_arr.push(unsorted_data_columns)
})
return unsorted_data_arr
}
//sort
function arr_sort(unsorted_data_arr, order, i){ //ascending, descending
let sorted_data_arr
if(order === 'ascending') {
sorted_data_arr = [...unsorted_data_arr].sort(function(a, b) {
if(typeof a[i] === 'string'){
return a[i].localeCompare(b[i])
}else{
return a[i] - b[i]
}
})
}else if(order === 'descending') {
sorted_data_arr = [...unsorted_data_arr].sort(function(b, a) {
if(typeof a[i] === 'string'){
return a[i].localeCompare(b[i])
}else{
return a[i] - b[i]
}
})
}else{err('[arr_sort] Out of range')}
return sorted_data_arr
}
//list_sort
function list_sort(order, i){
//[index, Title, View, DM, tm_str, TM, view_fmt, dm_fmt] = [0, 1, 2, 3, 4, 5, 6, 7]
//let header_column_names = ['重置', 'Title', 'View', 'DM', 'TM_str', 'TM', 'View_fmt', 'DM_fmt']
$('.video-section-list').add('.cur-list').each((index)=>{
let cards = store(index)
let unsorted_data_arr = bulid_sort_arr(cards)
let sorted_data_arr = arr_sort(unsorted_data_arr, order, i)
restore(sorted_data_arr, unsorted_data_arr, cards, index)
})
}
$('#hhh_listsort').off('click.hhh_listsort')
$('#hhh_listsort').on('click.hhh_listsort', function(e){
$('.hhh-listsort-head').css('opacity', 0.7)
let $head = $(e.target)
let sort = $head.attr('sort')
let text = $head.text().trim()
$head.css('opacity', 0.91)
if(sort === 'none'){
$head.attr('sort', 'descending')
.removeClass('hhh-listsort-head-asc')
.addClass('hhh-listsort-head-desc')
}else if(sort === 'ascending'){
$head.attr('sort', 'descending')
.removeClass('hhh-listsort-head-asc')
.addClass('hhh-listsort-head-desc')
}else if(sort === 'descending'){
$head.attr('sort', 'ascending')
.removeClass('hhh-listsort-head-desc')
.addClass('hhh-listsort-head-asc')
}else{err('[hhh_listsort click] Out of range')}
if(text === '重置'){
list_sort('ascending', header_column_names.indexOf(text))
$('.hhh-listsort-head').removeClass('hhh-listsort-head-asc')
.removeClass('hhh-listsort-head-desc')
}else{
// console.time('1')
list_sort($head.attr('sort'), header_column_names.indexOf(text))
// console.timeEnd('1')
}
reals_to_draws = bulid_real_to_draw()
// log('click.hhh_listsort:', reals_to_draws)
})
}
add_listsort()
reset_setSize()
keep_video_centered()
header_sort()
requestAnimationFrame(()=>false)
// console.timeEnd('main2')
})
})
}
//视频列表加长后,调节点击视频后滚动到中间
function new_video_scroll(){
if(LIST_TYPE !== VIDEO_LIST) return
let func = $('.base-video-sections-v1')[0]?.__vue__?.openSectionAndScrollToVideo
// log($('.base-video-sections-v1')[0]?.__vue__?.openSectionAndScrollToVideo)
if(func === undefined) return
// log('---openSectionAndScrollToVideo---')
try {
let t = Object.prototype.toString.call(func).slice(1,-1).split(' ')[1]
// log(t)
if(t.includes('Proxy') === true) return
func[Symbol.toStringTag] = 'Proxy-' + t
let handler = {
apply(target, ctx, args) {
// log(ctx.curVideoIndex)
let h = parseInt($('.video-episode-card')[1]?.offsetTop - $('.video-episode-card')[0]?.offsetTop)
h = isNaN(h) === true ? 34 : h
let $list = $('.video-sections-content-list')
let count = parseInt(($list[0]?.offsetTop + $list.height()/2 - 0 - 140) / h) //计算大约需要多滚动几个item
function draw_to_real(idx){
if(+idx < 0) idx = 0
if($('.hhh_episode_view').length <= 0) return +idx
return +$($('.hhh_episode_view').get(idx)).attr('real_idx') - 1
}
function real_to_draw(section_idx, video_idx){
let draw_idx = video_idx
$(`.video-section-list.section-${section_idx} .hhh_episode_view`).each((i,v)=>{
if(+$(v).attr('real_idx') === video_idx+1) {
draw_idx = i
return false
}
})
return draw_idx
}
let real_idx = ctx.curVideoIndex
let draw_idx = real_to_draw(ctx.curSectionIndex, ctx.curVideoIndex)
// log(real_idx, draw_idx, draw_to_real(draw_idx - count), count, draw_idx - count, $('.video-sections-item')[ctx.curSectionIndex].offsetTop)
ctx.curVideoIndex = draw_to_real(draw_idx - count)
Reflect.apply(...arguments)
// log('real_idx:', real_idx, 'draw_idx:', draw_idx, 'count:', count, 'draw_idx - count', draw_idx - count, 'ctx.curVideoIndex:', ctx.curVideoIndex)
if(draw_idx - count < 0){ //后续保证滚动到中间
let middle = parseInt($list.height()/2 - h/2)
$list.animate({ scrollTop: $(`.video-section-list.section-${ctx.curSectionIndex} .video-episode-card:eq(${draw_idx})`)[0].offsetTop - $list[0].offsetTop - middle }, 2000)
}
ctx.curVideoIndex = real_idx
// t.prototype.onEnded = function() {
// this.bufferAtom.checkBufferStatus(!1),
// this.bufferAtom.checkLaggingStatus(!1),
// this.patchAdvStore.hasLeftVideoToPlay() ? this.rootPlayer.emit(s.p.PATCH_ADV_PLAY_ENDED) : this.rootPlayer.emit(s.p.MEDIA_ENDED)
// }
},
}
$('.base-video-sections-v1')[0].__vue__.openSectionAndScrollToVideo = new Proxy(func, handler)
} catch (error) {
console.error(error);
// Expected output: ReferenceError: nonExistentFunction is not defined
// (Note: the exact output may be browser-dependent)
}
}
old_obj_convert_new()
const $multipart_progress = init(open)
if($multipart_progress === OFF) return false
//update_obj()
counter_obj()
update_progress()
update_title($multipart_progress)
init_sort(status)
new_video_scroll()
}
run(open, run_count++)
}
//给列表添加总时长 & 标注进度等
function add_to_video_sections_head(){
// log('======add_to_video_sections_head======')
//统计list秒数
function get_list_second($items, index){
//all
let second = 0
let begin = index === undefined ? 0 : index
let end = index === undefined ? $items.length - 1 : index
//log(index, begin, end)
for(; begin <= end; ++begin){
second += timestr_to_second($items.eq(`${begin}`).text()?.match(/([\d:]+)/)?.[1])
}
return second
}
function add_total_time($wrap, second){
if(!$wrap) return false
const id = 'hhh_total_time'
if($(`#${id}`).length <= 0){
$(``).appendTo($wrap)
}
let hour = ((second / (60*60/2)).toFixed(0)/2).toFixed(1) //0.5的倍数
$(`#${id}`).text(`总时长: ${sec2str(second)}(${hour}小时)`)
.attr('total-second', second)
}
function init(){
let $items = $('.video-section-list .video-episode-card__info-duration') //合集
let $left = $('.second-line_left')
if($items.length <= 0) {
$items = $('.list-box .duration') //选集
$left = $('.head-left')
}
const id = 'hhh_mysectionns_head'
if($items.length > 0){
if($(`#${id}`).length <= 0){
$left.wrap(``).parent()
}
}
return [$(`#${id}`), $items]
}
let [$wrap, $items] = init()
add_total_time($wrap, get_list_second($items))
//支持视频选集/合集(选集是单个BV号,合集是多个BV号)
memory_multipart_progress(config.getCheckboxSettingStatus('memoryProgress'), [config.getCheckboxSettingStatus('sortList')])
}
//搜索界面自动展开更多筛选
function auto_more_conditions(){
waitForTrue(()=>{
if($('.more-conditions.ov_hidden').length > 0)
$('.vui_button.vui_button--active-shrink.i_button_more').click()
return $('.more-conditions.ov_hidden').length <= 0
}, ()=>{})
}
//新版评论图片,点击图片返回
function return_comment(){
let $image_wrap = $('.show-image-wrap')
let $image_content = $('.image-content')
if($image_content[0].id !== 'hhh_show_image_wrap'){
$image_content[0].id = 'hhh_show_image_wrap'
//点击图片关闭图片:相对于右上角X
$image_content.click(()=>{
$('.operation-btn-icon.close-container').click()
})
//点击空白位置前后轮播图片:相当于左右箭头
$image_wrap.click((e)=>{
let wrap = $image_wrap[0].getBoundingClientRect()
let image = $image_content[0].getBoundingClientRect()
let clientX = e.clientX
if(clientX >= wrap.left && clientX <= image.left) { $('.operation-btn-icon.last-image').click(); return false }
if(clientX <= wrap.right && clientX >= image.right) { $('.operation-btn-icon.next-image').click(); return false }
})
//设置不透明度,防止遮挡
$('.preview-list').css('opacity', '0.5')
}
}
//https://api.bilibili.com/x/web-interface/archive/relation?aid=896486345&bvid=BV1CA4y1S7fS //得到投币数量
//初始化
function init() {
//读取设置 设置信息 && 快捷键信息
config.getCheckboxSetting()
// log('%%%%%%%%%%%%%%%%%%',window.location.href, geth5Player(), geth5Player()?.['tagName'], geth5Player()?.['baseURI'])
waitForTrueNoErr(()=>(h5Player = geth5Player()) !== undefined, ()=>{
function get_ver(){
let video_ver = window?.player?.getFormattedLogs()?.match(/version:\s*([\d.]+)/)?.[1]
let bili_ver = $('#app').length > 0 ? BILI_3_X_VIDEO_V1 :
$('#__next').length > 0 ? BILI_3_X_MOVIE : undefined
return [video_ver, bili_ver]
}
[video_ver, ver] = get_ver()
bb_config.set_bb(ver)
window.hhh_bb = bb
function lazyload(fn_arr){
let exclude_kv_body = {
[BILI_3_X_VIDEO_V1]: {
k: ['danmukuTop', 'danmukuTopClose', 'danmukuBottom', 'danmukuBottomClose', 'biliDlgM', 'coinDlgCoin', 'coinDlgCloseBtn', 'coinDlgOkBtn', 'playPBP',
'playTipWrap2', 'playCtrlSubtitle', 'playWatchLater', 'playTipWrap', 'playListAutoPlay'],
v: ['.video-toolbar-left .video-like.on', '.video-toolbar-left .video-coin.on', '.video-toolbar-left .video-fav.on', '.coin-dialog-mask .coin-btn',
'.bpx-player-volume-hint-text', '.bpx-player-volume-hint-icon', '.bpx-player-hotkey-panel', '.bili-dialog-m', '.coin-dialog-mask',
'.bpx-player-hotkey-panel-close', '.bpx-player-info-close', '.bpx-player-info-container', '.info-line','.bpx-player-top-mask',
'.bili-dialog-m .bi-btn', '.bpx-player-volume-hint', '.bpx-player-electric-jump'],
},
[BILI_3_X_MOVIE]: {
k: ['danmukuTop', 'danmukuTopClose', 'danmukuBottom', 'danmukuBottomClose', 'biliDlgM', 'coinDlgCoin', 'coinDlgCloseBtn', 'coinDlgOkBtn', 'playPBP',
'playTipWrap2', 'playCtrlSubtitle', 'playWatchLater', 'likeon' , 'coinon', 'switchDot', 'like', 'coin', 'playListAutoPlay'
],
v: ['.like-info.active', '.coin-info.active', '.collect-info.active', '.coin-dialog-mask .coin-btn', '.bpx-player-volume-hint', '.bili-dialog-m',
'.bpx-player-volume-hint-text', '.bpx-player-volume-hint-icon', '.bpx-player-hotkey-panel', '.coin-dialog-mask', '.bpx-player-electric-jump',
'.bpx-player-hotkey-panel-close', '.bpx-player-info-close', '.bpx-player-info-container', '.info-line','.bpx-player-top-mask'],
},
}
function check_dom1(exclude_kv, is_show) {
// log('---check_dom1---',exclude_kv)
let exclude_k = exclude_kv['k']
let exclude_v = exclude_kv['v']
for(let [k, v] of Object.entries(bb)){
//if(!!k && exclude_k.indexOf(k) !== -1) log(k,v); //test
if(!!k && exclude_k.indexOf(k) !== -1) continue;
// if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) log( k, exclude_v.indexOf(v) +' - '+$(v).length+' - '+v ) //test
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) {
if(is_show) log( k, exclude_v.indexOf(v) +' - '+$(v).length+' - '+v )
return false
}
}
return true
}
function check_dom2(){
let checked_dom = [ {cark:['.video-page-card-small', '.RecommendItem_wrap__5sPoo', '.recommend-video-card']}, {comment:['.comment-container .reply-list']} ]
let ret = checked_dom.every(e => {
let $t = $()
Object.values(e)[0].forEach(v=>{ $t = $t.add($(v)) })
// log(Object.keys(e), $t.length)
if($t.length > 0) return true
})
return ret
}
function check_attr(){
return window?.bpNC_1
}
function is_run(exclude_kv, is_show){
// log(check_dom1(exclude_kv, is_show) , check_dom2() , check_attr())
return check_dom1(exclude_kv, is_show)
&& check_dom2()
// && check_attr()
}
function fn_run(fn_arr){
fn_arr.forEach(v=>v())
}
function waitForTrue2(ifTrue, callback, ifArgs, callArgs, time=100) {
if(--time < 0) { err('waitForTrue2 超时 '+ifTrue); return false }
const fn = waitForTrue2
//let fn = arguments.callee;
if (ifTrue(...ifArgs, false)) {
callback(...callArgs); return true
} else {
setTimeout(function() { fn(ifTrue, callback, ifArgs, callArgs, time); }, 50)
}
}
if(ver !== undefined) waitForTrue2(is_run, fn_run, [exclude_kv_body[ver]], [fn_arr], 100)
else err('未知bilibili版本')
// waitForTrue(()=>{
// check_dom.forEach(e => {
// //console.log(e, $(e).length)
// for(let [k,v] of Object.entries(e)){
// console.log(v)
// let $t = $(v[0])
// v.slice(1,-1).forEach(e=>{
// $t = $t.add($(e))
// })
// console.log($t.length)
// }
// })
// }, ()=>{
// check_dom.forEach(element => {
// log(element, $(element).length)
// });
// })
// waitForTrue(()=> window?.bpNC_1, ()=>{
// log(window.bpNC_1.config.aid)
// fn_run(fn_arr)
// })
// log('^^^^^^^^^1',window?.user?.__ob__?.dep?.id, window.__VUE__)
// if(ver !== undefined) waitForTrue(()=>window?.user?.__ob__?.dep?.id && window.__VUE__, ()=>{
// log('^^^^^^^^^2',window?.user?.__ob__?.dep?.id, window.__VUE__)
// // log(window.__MIRROR_CONFIG__.config.whiteScreen.checkDom)
// // window.__MIRROR_CONFIG__.config.whiteScreen.checkDom.forEach((v,i)=>{
// // console.log(i,v,$(v).length)
// // })
// // fn_run(fn_arr)
// })
// else err('未知bilibili版本')
}
let eve = ['loadstart', 'durationchange', 'loadedmetadata', 'loadeddata', 'progress', 'canplay', 'canplaythrough'] //test
eve = ['loadeddata']
h5Player = geth5Player()
eve.forEach((v)=>{
$(h5Player).off(`${v}.hhh`)
$(h5Player).on(`${v}.hhh`,(e)=>{
// log(e.type)
if(e.type === 'loadeddata'){
waitForTrue(()=> window?.__INITIAL_STATE__?.videoData?.bvid === window?.__INITIAL_STATE__?.bvid, ()=>{
lazyload([run_once, video_loaded_run]) //video_loaded_run
})
}
})
})
})
// }
/* var box = document.getElementById("hhh");
//配置选项
var config = { childList: true, subtree: true, attributes: true };
var observer = new MutationObserver(function (mutationsList, observer) {
for (var mutation of mutationsList) {
const target = mutation.target;
//typeof target.className === 'string' && target.className !== '' && log(target.className);
if (mutation.type == 'childList') {
//console.log('子元素被修改');
}
else if (mutation.type == 'attributes') {
//console.log(mutation.attributeName + '属性被修改');
}
}
});
//开始观测
observer.observe(document.body, config); */
// GM_setValue('zw_test', a);
// console.log(GM_getValue('zw_test'));
// console.log(GM_getValue('zw_test').name);
let is_card_load = true
let is_content_load = null
let is_rec_list_load = null
let is_homepage_load = true
let is_fav_list_load = true
let is_history_break = null
let is_run_3X_break = true
let run_load = true
let run_done = false
let dm_t
let clickitem_name
let class_name_obj = {}
let old_url
new MutationObserver((mutations, observer) => {
mutations.forEach(mutation => {
function show_class_name(class_name_obj){ //显示查找 className个数
function show_appoint_num(min, max){
for(let [k,v] of Object.entries(class_name_obj)){
if(max === -1){
if(v >= min) log(k,v)
}else{
if(v >= min && v <= max) log(k)
}
}
}
for(let i=0; i<=10; i++){
if(i<10){
log(`--------------[${i}]----------------`);
show_appoint_num(i,i)
} else if(i===10){
log(`--------------[${i}+]----------------`);
show_appoint_num(i,-1)
}
}
log('--------------End----------------')
return
for(let [k,v] of Object.entries(class_name_obj)){
log(k+' - '+v)
let arr=[];
//for (let [k, v] of Object.entries(bb)) { !!v && v[0] === '.' && $(v).length !== -1 && arr.push(v+' - '+$(v).length) && 0 && log(v+' - '+$(v).length); }
for(let i=0; i<=10; i++){
if(i<10){
log(`--------------[${i}]----------------`);
arr.forEach(function(v){
+v.slice(-1) === i && v.slice(-2,-1) === ' ' && log(v);
})
} else if(i===10){
log(`--------------[${i}+]----------------`);
arr.forEach(function(v){
$.isNumeric(parseInt(v.slice(-2,-1))) && log(v);
})
}
}
log('--------------End----------------')
}
log(class_name_obj)
return;
//for (let [k, v] of Object.entries(bb)) { !!v && v[0] === '.' && $(v).length !== length && log(v+' - '+$(v).length); }
if(!!ver) { bb = {}; bb_config.set_bb(ver) }
let arr=[];
for (let [k, v] of Object.entries(bb)) { !!v && v[0] === '.' && $(v).length !== -1 && arr.push(v+' - '+$(v).length) && 0 && log(v+' - '+$(v).length); }
for(let i=0; i<=10; i++){
if(i<10){
log(`--------------[${i}]----------------`);
arr.forEach(function(v){
+v.slice(-1) === i && v.slice(-2,-1) === ' ' && log(v);
})
} else if(i===10){
log(`--------------[${i}+]----------------`);
arr.forEach(function(v){
$.isNumeric(parseInt(v.slice(-2,-1))) && log(v);
})
}
}
log('--------------End----------------')
//log(arr)
}
const target = mutation.target
// log($(geth5Player()).length)
//class_name_obj[target.className] = class_name_obj?.[target.className] === undefined ? 1 : ++class_name_obj[target.className]
// typeof target.className === 'string' && target.className !== '' && log(target.className)
// let $item_active = $('.list-box .on, .video-episode-card__info-playing')
// let name = $item_active.text()
// log(name)
//typeof target.className === 'string' && target.className !== '' && log($('.rec-list .video-page-card').length);
//干净链接
if(old_url !== window.location.href) { old_url = clear_url() }
//const stage = mutation.previousSibling && target.getAttribute('stage')
if($('.bilibili-player-video-wrap').length === 1){ //2.X
// if($('#app').hasClass('app-v1')){
// log("2.X“V3版”加载完毕");
// bb_config.set_bb(BILI_3_X_VIDEO_V1);
// run();
// }else{
// log("2.X“V2版”加载完毕");
// bb_config.set_bb(BILI_2_X_V2);
// run();
// }
} else if(1&&typeof target.className === 'string' && (target.className === 'bui-select-list-wrap#####' || target.className === 'rec-list####') ) {
//bug?? bpx-player-control-top 会激活重新加载视频
// clearTimeout(is_rec_list_load)
// is_rec_list_load = setTimeout(function() {
// // log('订阅合集列表加载完毕2222222222222222222222'); expand_list(config.getCheckboxSettingStatus('expandList'), config.getCheckboxSettingArgs('expandList', 'columns'));
// log("连播列表加载"); run_rec_list_newtab(config.getCheckboxSettingStatus('openVideoInNewTab'));
// add_to_video_sections_head() //列表加入总时长等
// list_filter() //合集列表关键字过滤
// //列表加入总时长
// //add_total_time()
// }, 200);
//} else if(1&&typeof target.className === 'string' && (target.className === 'bpx-player-control-top###' || target.className === 'rec-list###')) {
//|| target.className.includes('header-v2 win webscreen-fix') === true
} else if(1&&typeof target.className === 'string' && (target.className.includes('teleport') === true
|| target.className.includes('header-v2 win webscreen-fix') === true
|| target.className.includes('main-container') === true
|| target.className.includes('video-toolbar-container') === true)) {
log("投币快捷设置或添加到收藏夹关键字过滤")//***
//log(target.className)
collection_filter(config.getCheckboxSettingStatus('collectionFilter'))
set_dialog('coin', target.className)
//} else if(!bb_type && typeof target.className === 'string' && target.className === 'bpx-player-loading-panel-text') { //3.X pbp-tip bpx-player-loading-panel-text
//视频
} else if(0&&typeof target.className === 'string' && ((target.className === 'bui-select-list-wrap' && run_load === true) || target.className === 'rec-list')) { //3.X pbp-tip bpx-player-loading-panel-text
function get_ver_____(){
let ver_reg = $('.bpx-player-loading-panel-text').length > 0? $('.bpx-player-loading-panel-text').text().match(/(\d+).(\d+).(\d+)-(\w+)/): null;
let ver;
if(ver_reg === null) { ver = null; ver_reg = []}
else if($('#app').find('.l-con').length > 0) ver = BILI_3_X_VIDEO;
else if($('#app').find('.plp-l').length > 0) ver = BILI_3_X_MOVIE; //todo plp-l
else if($('#app.app-v1').length > 0) ver = BILI_3_X_VIDEO_V1; //todo plp-l
else ver = BILI_2_X;
//log(ver_reg[0]+' | '+ver)
//log($('#app').find('.l-con').length+' | '+$('#app').find('.plp-l').length)
return [ver, ver_reg[0]];
}
function get_ver__(){
let ver_reg = $('.bpx-player-loading-panel-text').length > 0? $('.bpx-player-loading-panel-text').text().match(/(\d+).(\d+).(\d+)-(\w+)/): null
//log(ver_reg)
ver_reg ??= $('.bpx-player-info-log .info-title').text().match(/[\d.]+/)
// log($('.bpx-player-info-log .info-title').length)
// log('[2]',window?.player?.getFormattedLogs().match(/version:\s*([\d.]+)/)?.[1])
ver_reg = window?.player?.getFormattedLogs().match(/version:\s*([\d.]+)/)?.[1]
let ver
// if(ver_reg === null) { ver = null; ver_reg = [] }
if($('#app').find('.l-con').length > 0) ver = BILI_3_X_VIDEO;
else if($('#__next').find('.plp-l').length > 0) ver = BILI_3_X_MOVIE; //todo plp-l
else if($('#app').length > 0) ver = BILI_3_X_VIDEO_V1; //todo plp-l
else ver = BILI_2_X;
//log(ver_reg[0]+' | '+ver)
//log($('#app').find('.l-con').length+' | '+$('#app').find('.plp-l').length)
return [ver, ver_reg];
}
function show_bb_config(ver){ //显示查找 className DOM个数
//for (let [k, v] of Object.entries(bb)) { !!v && v[0] === '.' && $(v).length !== length && log(v+' - '+$(v).length); }
if(!!ver) { bb = {}; bb_config.set_bb(ver) }
let arr=[];
for (let [k, v] of Object.entries(bb)) { !!v && v[0] === '.' && $(v).length !== -1 && arr.push(v+' - '+$(v).length) && 0 && log(v+' - '+$(v).length); }
for(let i=0; i<=10; i++){
if(i<10){
log(`--------------[${i}]----------------`);
arr.forEach(function(v){
+v.slice(-1) === i && v.slice(-2,-1) === ' ' && log(v);
})
} else if(i===10){
log(`--------------[${i}+]----------------`);
arr.forEach(function(v){
$.isNumeric(parseInt(v.slice(-2,-1))) && log(v);
})
}
}
log('--------------End----------------')
//log(arr)
}
function isrun_3_x_movie() {
let exclude_k = ['danmukuTop', 'danmukuTopClose', 'danmukuBottom', 'danmukuBottomClose', 'biliDlgM', 'coinDlgCoin', 'coinDlgCloseBtn', 'coinDlgOkBtn', 'playPBP',
'playTipWrap2', 'playCtrlSubtitle', 'playWatchLater', 'likeon' , 'coinon', 'switchDot', 'like', 'coin' ];
let exclude_v = ['.like-info.active', '.coin-info.active', '.collect-info.active', '.coin-dialog-mask .coin-btn', '.bpx-player-volume-hint', '.bili-dialog-m',
'.bpx-player-volume-hint-text', '.bpx-player-volume-hint-icon', '.bpx-player-hotkey-panel', '.coin-dialog-mask', '.bpx-player-electric-jump',
'.bpx-player-hotkey-panel-close', '.bpx-player-info-close', '.bpx-player-info-container', '.info-line','.bpx-player-top-mask'];
for(let [k, v] of Object.entries(bb)){
//if(!!k && exclude_k.indexOf(k) !== -1) log(k,v); //test
if(!!k && exclude_k.indexOf(k) !== -1) continue;
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) log( k, exclude_v.indexOf(v) +' - '+$(v).length+' - '+v ); //test
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) return false;
}
return true;
}
function isrun_3_x_video() {
let exclude_k = ['danmukuTop', 'danmukuTopClose', 'danmukuBottom', 'danmukuBottomClose', 'biliDlgM', 'coinDlgCoin', 'coinDlgCloseBtn', 'coinDlgOkBtn', 'playPBP',
'playTipWrap2', 'playCtrlSubtitle', 'playWatchLater', ];
let exclude_v = ['.ops .like.on', '.ops .coin.on', '.ops .collect.on', '.coin-dialog-mask .coin-btn', '.bpx-player-volume-hint', '.bpx-player-electric-jump',
'.bpx-player-volume-hint-text', '.bpx-player-volume-hint-icon', '.bpx-player-hotkey-panel', '.bili-dialog-m', '.coin-dialog-mask',
'.bpx-player-hotkey-panel-close', '.bpx-player-info-close', '.bpx-player-info-container', '.info-line','.bpx-player-top-mask',
'.bili-dialog-m .bi-btn'];
for(let [k, v] of Object.entries(bb)){
//if(!!k && exclude_k.indexOf(k) !== -1) log(exclude_k.indexOf(k) +' - '+k+' - '+v);
if(!!k && exclude_k.indexOf(k) !== -1) continue;
//if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) log(exclude_v.indexOf(v) +' - '+$(v).length+' - '+v);
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) return false;
}
return true;
}
function isrun_3_x_video_v1() {
let exclude_k = ['danmukuTop', 'danmukuTopClose', 'danmukuBottom', 'danmukuBottomClose', 'biliDlgM', 'coinDlgCoin', 'coinDlgCloseBtn', 'coinDlgOkBtn', 'playPBP',
'playTipWrap2', 'playCtrlSubtitle', 'playWatchLater', 'playTipWrap', ];
let exclude_v = ['.video-toolbar-left .video-like.on', '.video-toolbar-left .video-coin.on', '.video-toolbar-left .video-fav.on', '.coin-dialog-mask .coin-btn', '.bpx-player-volume-hint', '.bpx-player-electric-jump',
'.bpx-player-volume-hint-text', '.bpx-player-volume-hint-icon', '.bpx-player-hotkey-panel', '.bili-dialog-m', '.coin-dialog-mask',
'.bpx-player-hotkey-panel-close', '.bpx-player-info-close', '.bpx-player-info-container', '.info-line','.bpx-player-top-mask',
'.bili-dialog-m .bi-btn'];
for(let [k, v] of Object.entries(bb)){
//if(!!k && exclude_k.indexOf(k) !== -1) log(exclude_k.indexOf(k) +' - '+k+' - '+v);
if(!!k && exclude_k.indexOf(k) !== -1) continue;
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) log(exclude_v.indexOf(v) +' - '+$(v).length+' - '+v);
if(!!v && exclude_v.indexOf(v) === -1 && $(v).length === 0) return false;
}
return true;
}
//clearTimeout(run_load);
run_load = false
//log('-------run_load----------')
//log(target.className)
//log($('.bpx-player-loading-panel-text').length)
clearTimeout(run_done)
run_done = setTimeout(function() {
//log(`-------run_load2----------`)
//log($('.bpx-player-loading-panel-text').text())
let ver_string
[ver, ver_string] = get_ver__();
log(`[${ver_string}][${ver}]加载完毕`);
//if(!ver || !ver_string) {
if(!ver) {
clearTimeout(run_load); return true;
}
// log('---bb_config.set_bb(ver);---')
bb_config.set_bb(ver)
////////////////////////
////////////////////////
// show_bb_config()
//setTimeout(()=>show_class_name(class_name_obj),2000)
//show_class_name(class_name_obj)
//return;
////////////////////////
////////////////////////
function run_(){
// run_2once()
// video_loaded_run() //视频加载时执行
//log('订阅合集列表加载完毕'); expand_list(config.getCheckboxSettingStatus('expandList'), config.getCheckboxSettingArgs('expandList', 'columns'))
log("连播列表加载"); run_rec_list_newtab(config.getCheckboxSettingStatus('openVideoInNewTab'))
list_filter() //合集列表关键字过滤
add_to_video_sections_head() //列表加入总时长等
//log('add_to_video_sections_head: ',target.className)
//setTimeout(()=>run_load = true, 500)
}
if(ver === BILI_3_X_VIDEO) waitForTrue(isrun_3_x_video, run_);
else if(ver === BILI_3_X_VIDEO_V1) waitForTrue(isrun_3_x_video_v1, run_);
else waitForTrue(isrun_3_x_movie, run_);
// log('订阅合集列表加载完毕'); expand_list(config.getCheckboxSettingStatus('expandList'), config.getCheckboxSettingArgs('expandList', 'columns'));
// log("连播列表加载"); run_rec_list_newtab(config.getCheckboxSettingStatus('openVideoInNewTab'));
// add_to_video_sections_head() //列表加入总时长等
}, 800);
//动态首页
} else if(typeof target.className === 'string' && target.className==='bili-dyn-list__items'){
clearTimeout(is_content_load); //log(!!config.getCheckboxSettingStatus('showDynListContent') || 1)
is_content_load = setTimeout(function() { log("动态首页加载完毕"); run_content(!!config.getCheckboxSettingStatus('showDynListContent') || true); }, 200)
//当前在线
} else if(typeof target.className === 'string' && target.className === 'avatar' && target.baseURI.indexOf('www.bilibili.com/video/online.html') !== -1){
log("当前在线加载完毕");
run_online_preview(config.getCheckboxSettingStatus('onlinePreview'))
//首页
} else if(typeof target.className === 'string' && window.location.href.match(/https?:\/\/www.bilibili.com\/?$/) && is_homepage_load === true){
is_homepage_load = false
waitForTrue(()=> $('.rcmd-box-wrap').length === 1 || $('.bili-grid.short-margin.grid-anchor:first').length === 1 || $('.recommended-swipe.grid-anchor:first').length === 1, () => {
if($('#app').length > 0) ver = BILI_3_X_VIDEO
else if($('#i_cecream main.bili-layout').length > 0) ver = BILI_3_X_VIDEO_V1
else if($('#i_cecream main.bili-feed4-layout').length > 0) ver = BILI_4_X_V1
else ver = null
bb_config.set_bb(ver)
log(`[${ver}]-首页-加载完毕`)
run_save_recommend_list(config.getCheckboxSettingStatus('saveRecommendList'))
run_add_carousel_slide()
run_add_online()
run_adblock_remove()
// run_go_back_new_version()
})
//第一时间执行
} else if(0&&typeof target.className === 'string' && window.location.href.match(/https?:\/\/www.bilibili.com\/.+/) && is_homepage_load === true){
//收藏夹
} else if(typeof target.className === 'string' && target.className==='be-scrollbar fav-list-container ps'){
// log(config.getCheckboxSettingStatus('favSetting'))
// log(config.sets)
clearTimeout(is_fav_list_load)
is_fav_list_load = setTimeout(function() { log("收藏夹设置完毕")
// log(config.getCheckboxSettingStatus('favSetting'))
run_fav(config.getCheckboxSettingStatus('favSetting')); }, 200)
//三连和选择弹窗
} else if(typeof target.className === 'string' && target.className.indexOf('bili-guide-all bili-guide') !== -1){
hideThreePopup(config.getCheckboxSettingStatus('hideThreePopup'))
//打分弹窗
} else if(typeof target.className === 'string' && target.className.indexOf('bili-score bili-no-event') !== -1){
hideScorePopup(config.getCheckboxSettingStatus('hideScorePopup'))
//搜索界面自动展开更多筛选
} else if(typeof target.className === 'string' && target.className.indexOf('header-entry-avatar') !== -1){
auto_more_conditions()
//新版评论图片,任意点击返回
} else if(typeof target.className === 'string' && target.className.indexOf('show-image-wrap') !== -1){
return_comment()
// } else if(typeof target.className === 'string' && target.className==='history-list'){
// clearTimeout(is_history_break);
// is_history_break = setTimeout(function() { log("历史记录加载完毕"); run_history()}, 200);
//clearTimeout(is_rcmd_box_break);
//is_rcmd_box_break = setTimeout(function() { log("推荐列表加载完毕"); run_recommend_box()}, 50);
// } else if(is_card_load === false && typeof target.className === 'string' && target.className === 'card' && $(target).find('.video-container .content').length){
// is_card_load = true;
// log("2.X动态首页加载完毕");r
// run_card(); //搞笑,刚写完,2.70.7就有了
// removeMostViewedListener(config.getCheckboxSettingStatus('removeMostViewedListener'));
}
});
}).observe(document, {
childList: true,
subtree: true,
//attributes: true,
});
}
init()
}
}
hhh_lightoff_main.init()