kjtsune / embyToLocalPlayer

etlp - Emby/Jellyfin 调用外部本地播放器,并回传播放记录。适配 Plex。
595 stars 38 forks source link

去除Emby首页广告 #69

Closed verygoodlee closed 1 month ago

verygoodlee commented 1 month ago

免费版Emby首页偶尔会出现这个Discover Emby Premiere的广告,有点烦, 屏幕截图 2024-08-27 224207 就顺带写两行代码去一下广告,测了下应该没有误杀其他元素

kjtsune commented 1 month ago

这种交给广告拦截插件比较合适。 以下是 uBlock Origin 规则。前面星号好像要删掉。这广告刷新一下就没有了,有点难测。

##.emby-scrollbuttons-scroller.focusable.section-appinfo.verticalSection-cards.verticalSection
##.emby-scrollbuttons-scroller.section-appinfo.verticalSection-cards.verticalSection
##.emby-scrollbuttons-scroller.focusable.section-appinfo.verticalSection
verygoodlee commented 1 month ago

确实很难测,用了一段时间,发现不管是用广告拦截插件还是用油猴脚本,都大概率拦不住, 因为那个div是延时出现的,页面刚加载完时还没有,大概过个0.3+秒出现, 等拦截插件或者脚本执行完毕之后,他才出现。 (广告拦截插件应该能拦截延迟出现的元素吧,可能规则写的有问题,不熟悉他的语法)

测试了下它出现的时间,大概就0.3秒

let t = 0;
const intervalId = setInterval(() => {
    let adDiv = document.querySelector('div.verticalSection.verticalSection-cards.section-appinfo.emby-scrollbuttons-scroller');
    console.log('时间: ', t, ' 广告div:', adDiv);
    if (adDiv) clearInterval(intervalId);
    t += 100;
}, 100);

image

要保证拦截住,还得在油猴脚本写定时器,等待那个div出现才行

verygoodlee commented 1 month ago

规则的问题,我用的AdGuard,星号通配符匹配所有域名不行,用具体的域名没问题

localhost##.verticalSection.verticalSection-cards.section-appinfo.emby-scrollbuttons-scroller

可看出AdGuard给它加了样式 image

kjtsune commented 1 month ago

uBlock Origin 我用别的非Emby网站测试,去掉前面星号应该就是匹配所有域名。AdGuard 估计也是。

verygoodlee commented 1 month ago

确实,不写域名就匹配所有