简体   繁体   English

在 Chrome Devtools 打开的情况下重新加载 Hulu 会导致奇怪的行为

[英]Reloading Hulu with Chrome Devtools open causes strange behavior

Background: I'm trying to create a chrome extension for Hulu.背景:我正在尝试为 Hulu 创建一个 chrome 扩展。 For now, all I'm concerned with is grabbing the titles of the movies/shows in the Comedy genre from the DOM.现在,我所关心的只是从 DOM 中获取喜剧类型的电影/节目的标题。

Prereq to recreate the issue: I feel terrible saying this, but a Hulu subscription.重新创建问题的先决条件:我觉得这很糟糕,但是订阅了 Hulu。 I can't seem to recreate it without logging in.我似乎无法在不登录的情况下重新创建它。

Steps to recreate the issue:重现问题的步骤:

const showLinks = [...document.getElementsByTagName("a")].filter(x => x.id.includes("title"));
console.log(showLinks);
  • The above should print a number greater than 0, basically just grabbed all links with "title" in their ID.上面应该打印一个大于 0 的数字,基本上只是抓取了 ID 中带有“title”的所有链接。 I may or may not pursue a better method later, just playing around for now.我以后可能会也可能不会追求更好的方法,只是暂时玩一下。
  • Refresh the page with the Devtools open打开 Devtools 刷新页面
  • Enter the above code snippet again.再次输入上面的代码片段。 You will now notice 0 selected elements.您现在会注意到 0 个选定的元素。 The look and feel of the page also changes for some reason.由于某种原因,页面的外观和感觉也会发生变化。

Any clues on why this is happening would be greatly appreciated.任何关于为什么会发生这种情况的线索将不胜感激。 Any suggestions on a better way to grab all the titles would also be quite welcome!任何关于获取所有标题的更好方法的建议也将非常受欢迎! Thanks :)谢谢 :)

Almost immediately realized my folly, the devtools defaulted to a Responsive view which must have fooled Hulu into thinking I was trying to access content through a mobile/tablet device.几乎立即意识到我的愚蠢,devtools 默认为响应式视图,这一定让 Hulu 误以为我正在尝试通过移动/平板设备访问内容。 The error does not occur after switching to a laptop device.切换到笔记本电脑设备后不会发生该错误。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM