从嵌入式脚本中获取 Javascript 中的 ID 作为变量

get the ID in Javascript as variable from embedded script

我正在尝试获取嵌入式脚本的视频 ID。这个 ID 每次都会为视频更改,所以我需要以某种方式获取它。

这是在 HTML 文档中添加的嵌入行:

<script src="https://content.jwplatform.com/players/80HZjDPO-V5C9t34F.js"></script>

这是它生成的内容:

<div id="botr_80HZjDPO_V5C9t34F_div" class="jwplayer jw-reset jw-state-paused jw-stretch-uniform jw-flag-aspect-mode jw-breakpoint-4 jw-flag-user-inactive" tabindex="0" aria-label="Video Player" role="application" style="width: 100%;">

这是我要抢的id:

id="botr_80HZjDPO_V5C9t34F_div"

我注意到这总是一样的:

botr_ ****** _V5C9t34F_div

我如何才能获取此 ID 并在我的 Javascript 中使用它?

可以在属性选择器中使用$来匹配字符串的结尾$("div[id$='_V5C9t34F_div']").

[name$=”value”]

Description: Selects elements that have the specified attribute with a value ending exactly with a given string. The comparison is case sensitive.