Greasy Fork

来自缓存

Greasy Fork is available in English.

b站推荐视频优化

将b站默认推荐视频从6个增加到20个,并修改排版

当前为 2021-04-14 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         b站推荐视频优化
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  将b站默认推荐视频从6个增加到20个,并修改排版
// @author       You
// @match        http://www.dianping.com/ajax/json/shopDynamic/allReview*
// @require       http://cdn.bootcss.com/jquery/3.1.0/jquery.min.js
// @require       https://unpkg.com/ajax-hook/dist/ajaxhook.min.js
// @include       http://www.dianping.com/shop/*
// @exclude       http://diveintogreasemonkey.org/*
// @exclude       http://www.diveintogreasemonkey.org/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    $.ajaxSetup({
     crossDomain: true,
     xhrFields:{
       withCredentials: true
     }

    })
 //   $('.video-card-reco:nth-child(n+7)').css('display':'block');
    $('#reportFirst1').css('width','0')
    $('.rcmd-box').css({'width':'100%','margin-bottom':'300px'})
    $('.b-wrap').css('width','1258px')
    $('#bilibili-player').css({'width':'797px','height': '618px'})
    $('.bui').css('display','none')
    $('.v-wrap').css({'max-width':'5000px','min-width':'10px'})
    $('.l-con').css('width','831px')
    $('.primary-menu-itnl').css('padding','0')
    commonSetting()
    addScript('https://unpkg.com/[email protected]/dist/ajaxhook.min.js')
    $(".change-btn").click(function(){
        sleep(500).then(() => {
           commonSetting()
        })
           $.get("https://api.bilibili.com/x/web-interface/index/top/rcmd?fresh_type=3", function(result){
                $('.rcmd-box div:nth-child(10)').nextAll().remove()
               var items = result.data.item
               for(let i=0; i<10; i++){
                   var videoUrl = items[i].uri
                   var videoImg = items[i].pic
                   var videoDesc = items[i].title
                   var videoUpName = items[i].owner.name
                   $('.rcmd-box').append(`<div class="video-card-reco"><div class="info-box"><a href=${videoUrl} target="_blank"><img src=${videoImg} alt=${videoDesc}><div class="info"><p title=${videoDesc} class="title">${videoDesc}</p><p class="up"><i class="bilifont bili-icon_xinxi_UPzhu"></i>${videoUpName}</p><p class="play">未知</p></div></a></div><div class="watch-later-video van-watchlater black"><span class="wl-tips" style="display:none;"></span></div></div>`)
               }
           });

    });
    // 这里写sleep之后需要去做的事情
/*   ah.proxy({
    onRequest: (config, handler) => {
        handler.next(config);
    },
    onError: (err, handler) => {
    },
    onResponse: (response, handler) => {
        if (response.config.url === '//api.bilibili.com/x/web-interface/index/top/rcmd?fresh_type=3') {
    //        if(flag) {
//                flag = !flag
//                handler.next(response)
//                return
//            } else {
//                flag = !flag
//            }
            handler.next(response)
            sleep(50).then(() => {
           commonSetting()
        })
        } else {
           handler.next(response)
        }

    }
})
*/
})()

function commonSetting(){
    $('.elevator .list-box').css('display','none')
    $('.rcmd-box div:nth-child(n+7)').css('display','block')
  //  $('.rcmd-box').css('margin-bottom','350px')
    $('.video-card-reco').css({'width':'248px','height':'135px'})
    $('.video-card-reco .info-box .info .title').css({'margin-top':'37px'})
}





function sleep (time) {
  return new Promise((resolve) => setTimeout(resolve, time));
}



function addScript(url){
    var script = document.createElement('script');
    script.setAttribute('type','text/javascript');
    script.setAttribute('src',url);
    document.getElementsByTagName('head')[0].appendChild(script);
}