哔哩哔哩的推荐机制很差,但是很自信,所以我把合集列表高度拉长,把不相关的推荐视频挤到下面去。
目前為
// ==UserScript==
// @name 拉长B站合集列表
// @namespace http://tampermonkey.net/
// @version 0.1
// @description 哔哩哔哩的推荐机制很差,但是很自信,所以我把合集列表高度拉长,把不相关的推荐视频挤到下面去。
// @author beibeibeibei
// @license MIT
// @match *.bilibili.com/video/*
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
let 最高合集列表高度 = 500;
let 检测时间间隔 = 5000;
let 外层容器 = document.querySelector("div.video-sections-content-list");
let 所有子内容 = document.querySelectorAll("div.video-episode-card");
let 外层容器2 = document.querySelector("div.cur-list");
let 所有子内容2 = document.querySelectorAll("div.cur-list > ul > li");
let timer = setInterval(function() {
if (外层容器){
let 待改高度 = parseFloat( window.getComputedStyle(外层容器 ,null).height );
let 合集个数 = 所有子内容.length;
let 单条高度 = parseFloat( window.getComputedStyle(所有子内容[0] ,null).height ) + parseFloat( window.getComputedStyle(所有子内容[0] ,null).marginBottom ) * 2;
let 修正高度 = 合集个数 * 单条高度;
if (修正高度 > 最高合集列表高度){
修正高度 = 最高合集列表高度;
}
if ( 待改高度 < 修正高度 ){
外层容器.style.maxHeight = 修正高度 + "px";
外层容器.style.height = 修正高度 + "px";
}
}
if (外层容器2){
let 待改高度 = parseFloat( window.getComputedStyle(外层容器2 ,null).height );
let 合集个数 = 所有子内容2.length;
let 单条高度 = parseFloat( window.getComputedStyle(所有子内容2[0] ,null).height ) + parseFloat( window.getComputedStyle(所有子内容2[0] ,null).marginBottom ) * 2;
let 修正高度 = 合集个数 * 单条高度;
if (修正高度 > 最高合集列表高度){
修正高度 = 最高合集列表高度;
}
if ( 待改高度 < 修正高度 ){
外层容器2.style.maxHeight = 修正高度 + "px";
外层容器2.style.height = 修正高度 + "px";
}
}
}, 检测时间间隔);
// Your code here...
})();