为浏览器使用自定义样式 sheet - 如何隐藏 netflix 上的特定节目?
Using Custom Style sheet for browser - How to hide specific shows on netflix?
我最近了解到我们可以使用自定义样式 sheets 来操纵互联网上网站的元素。
我有一个问题,我最终浪费了很多时间在 netflix 上狂看节目,后来我后悔这样做了。所以我想隐藏我上瘾的节目 - 在这种情况下 "Arrow"。
我相信在不久的将来还会有另一个我迷上的,我会用同样的技巧来隐藏它,直到我克服它。
来自 Netflix 的绿箭侠 CSS 是:
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
它嵌套在几个 div 中,最外面的 div 可能不同,因为节目可以在不同的滑块下多次显示。
我上面提到的这个 CSS 选择器的直接父级是:
<div class="bob-overlay bob-overlay-hidden">
<div class="bob-play-hitzone"></div>
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
Arrow
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
我尝试在该自定义样式中添加以下内容 sheet 但没有任何区别。
a[aria-label="Arrow"] { display: none; }
关于如何编写匹配和隐藏此节目的 css 选择器有什么建议吗?
听起来您可能想要隐藏包含带有 aria-label="Arrow"
的元素的 整个 bob-overlay
容器。 CSS 不能从 child select 变成 parent,但是你可以用 Javascript 很容易地做到这一点。安装像 Tampermonkey 这样的用户脚本管理器,然后搜索匹配 a[aria-label="Arrow"]
的元素,找到它们的祖先 .bob-overlay
s,并删除它们(或将它们的显示设置为 none):
for (const a of document.querySelectorAll('a[aria-label="Arrow"]')) {
a.closest('.bob-overlay').remove();
}
<div class="bob-overlay bob-overlay-hidden">
arrow - hide me
<div class="bob-play-hitzone"></div>
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
Arrow
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
</div>
</div>
<div class="bob-overlay bob-overlay-hidden">
not arrow, don't hide me
<div class="bob-play-hitzone"></div>
<a aria-label="Foobar" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
something else
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
</div>
</div>
如果元素是动态加载的并且在初始页面加载时不存在,您可能必须在 setTimeout
或(或 setInterval
轮询后 运行 JS,或 MutationObserver
).
整个用户脚本可能看起来像
// ==UserScript==
// @name Hide Arrow
// @include https://www.netflix.com/*
// @grant none
// ==/UserScript==
for (const a of document.querySelectorAll('a[aria-label="Arrow"]')) {
a.closest('.bob-overlay').remove();
}
我最近了解到我们可以使用自定义样式 sheets 来操纵互联网上网站的元素。
我有一个问题,我最终浪费了很多时间在 netflix 上狂看节目,后来我后悔这样做了。所以我想隐藏我上瘾的节目 - 在这种情况下 "Arrow"。
我相信在不久的将来还会有另一个我迷上的,我会用同样的技巧来隐藏它,直到我克服它。
来自 Netflix 的绿箭侠 CSS 是:
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
它嵌套在几个 div 中,最外面的 div 可能不同,因为节目可以在不同的滑块下多次显示。
我上面提到的这个 CSS 选择器的直接父级是:
<div class="bob-overlay bob-overlay-hidden">
<div class="bob-play-hitzone"></div>
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
Arrow
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
我尝试在该自定义样式中添加以下内容 sheet 但没有任何区别。
a[aria-label="Arrow"] { display: none; }
关于如何编写匹配和隐藏此节目的 css 选择器有什么建议吗?
听起来您可能想要隐藏包含带有 aria-label="Arrow"
的元素的 整个 bob-overlay
容器。 CSS 不能从 child select 变成 parent,但是你可以用 Javascript 很容易地做到这一点。安装像 Tampermonkey 这样的用户脚本管理器,然后搜索匹配 a[aria-label="Arrow"]
的元素,找到它们的祖先 .bob-overlay
s,并删除它们(或将它们的显示设置为 none):
for (const a of document.querySelectorAll('a[aria-label="Arrow"]')) {
a.closest('.bob-overlay').remove();
}
<div class="bob-overlay bob-overlay-hidden">
arrow - hide me
<div class="bob-play-hitzone"></div>
<a aria-label="Arrow" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
Arrow
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
</div>
</div>
<div class="bob-overlay bob-overlay-hidden">
not arrow, don't hide me
<div class="bob-play-hitzone"></div>
<a aria-label="Foobar" class="bob-jaw-hitzone" href="/title/70242081"></a>
<div class="bob-overview-wrapper">
<div class="bob-overview">
<a tabindex="0" data-uia="play-button" role="link" aria-label="Resume" class="bob-play-button playLink" href="/watch/80140962?trackId=14170286&tctx=1%2C0%2Cb9a98838-f436-4b89-ac66-7190b45402e6-32766795%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_77601417X3XX1581889779290%2Ccf1e7866-0b59-41c4-96bd-b10d5ca4cf61_ROOT">
<span class="play-button">
<svg class="svg-icon svg-icon-play-with-ring" focusable="true">
<use filter="" xlink:href="#play-with-ring">
</use>
</svg>
</span>
</a>
<div class="bob-title">
something else
</div>
<div class="bob-overview-resume-title-wrapper">
<div class="watched-title watched-title--bob-overview watched-title--no-wrap">
<span><b>S5:E7</b> "Vigilante"</span>
</div>
</div>
<div class="bob-content-warning-wrapper"></div>
</div>
</div>
</div>
如果元素是动态加载的并且在初始页面加载时不存在,您可能必须在 setTimeout
或(或 setInterval
轮询后 运行 JS,或 MutationObserver
).
整个用户脚本可能看起来像
// ==UserScript==
// @name Hide Arrow
// @include https://www.netflix.com/*
// @grant none
// ==/UserScript==
for (const a of document.querySelectorAll('a[aria-label="Arrow"]')) {
a.closest('.bob-overlay').remove();
}