您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Greasy Fork is available in English.
有的视频真的不想点开,比如恐怖的,连预览都不想看到,但却总是出现在首页上。现在点击视频预览图右上角的x,不喜欢的视频就会被移除,并被记录在localStorage里,以后都不会再出现在首页了(除非删除了浏览器缓存)。
当前为
// ==UserScript== // @name Bilibili屏蔽首页上不想看的视频 // @namespace Max's Scripts // @version 1.1 // @author Max // @include https://www.bilibili.com/* // @require http://libs.baidu.com/jquery/2.0.0/jquery.min.js // @grant none // @description 有的视频真的不想点开,比如恐怖的,连预览都不想看到,但却总是出现在首页上。现在点击视频预览图右上角的x,不喜欢的视频就会被移除,并被记录在localStorage里,以后都不会再出现在首页了(除非删除了浏览器缓存)。 // ==/UserScript== $('head').append(`<style> .bili-x-card {position: relative;} .bili-x-card > .x {position:absolute;width:15px;height:15px;top:0;right:0;font-size:15px;text-align:center;line-height:12px;color:#fff;cursor:pointer;z-index:99;display:none} .bili-x-card:hover > .x {display:block} </stlye>`); localStorage.blacklist = localStorage.blacklist || [] localStorage.keywords = localStorage.keywords || [] var findId = (module) => { let a = $('> .card-pic > a',module).get(0) || $('> .info-box > a',module).get(0) || $('>a',module).get(0) || module.href && module; let id = ((a.dataset && a.dataset['data-target-url'] || a.href).match(/(BV[0-9a-zA-Z]+|space\.bilibili\.com\/\d+|live\.bilibili\.com\/\d+|manga\.bilibili\.com\/detail\/mc\d+)/g) || [null])[0]; return id } setInterval(function(){ let cards = $('.video-card-common,.video-card-reco,.live-card,.manga-card'); let blacklist = localStorage.blacklist.split(','); let keywords = localStorage.keywords.split(','); cards.each((i, c)=>{ let card = $(c); if(card.is(':empty')) return; let xid = card.attr('xid'); if(xid){ if(blacklist.includes(xid)){ card.remove(); console.log('removed', xid.toString()); } } else { let x = $('<div class=x>x</div>') .click(function(e){ let card = this.parentNode; let id = findId(card); if(!id)return false; if(id.match(/\?/)) id = id.slice(0, id.indexOf('?')) blacklist.push(id); localStorage.setItem('blacklist', blacklist); $(this).parent().remove(); console.log('removed', id.toString()) e.stopPropagation(); if(card.href){ card.href = 'javascript:void(0)' card.target = '_self' } }); card.append(x).attr('xid', findId(card.get(0))).addClass('bili-x-card'); } }); }, 1000)