防止 divx Web 插件替换 html5 视频元素?
出于某种原因,我确信 DivX 的人们认为这一点很重要,没有直接的方法可以阻止他们的插件用他们喜欢的徽标替换页面上的所有视频元素。
我需要的是解决这个问题的方法,告诉插件跳过一些视频,即不要用可播放的内容替换它们。
For some reason I'm sure the folks at DivX think is important, there is no straightforward way to prevent their plugin from replacing all video elements on your page with they fancy logo.
What I need is a workaround for this, telling the plugin to skip some videos, i.e. not replace them with their playable content.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我通过放置一个空的 HTML 5 视频标签,然后将视频源标签放入正文 onload 事件中的 JavaScript 函数来解决这个问题。然后视频会出现在普通的 HTML 5 播放器中,而不是 DivX Web 播放器中。
例如
这会给 DivX 播放器:
但这会给普通的 html 5 播放器:
I got around this by putting an empty HTML 5 video tag, then putting in the video source tags in a JavaScript function in the body onload event. The video then comes up in the normal HTML 5 player and not the DivX web player.
e.g.
This would give the DivX player:
But this would give the normal html 5 player:
目前,没有 API 或方法可以阻止 divx 插件用占位符替换视频元素。 :-(
At this time, there is no API or means to block the divx plugin from replacing video elements with their placeholder. :-(
我开始对 divx 插件进行逆向工程,以找出可以采取哪些措施来禁用它。可以在此处找到一个示例,包括 divx-plugin 的完整源代码: http://jsfiddle.net/ z4JPB/1/
目前在我看来,一个可能的解决方案可以像这样工作:
appendChild
、replaceChild
和 < code>insertBefore - 这必须在执行 chrome 扩展的内容脚本之前发生。i started reverse-engineering the divx-plugin to find out what can be done to hack a way into disabling it. An example, including the complete sourcecode of the divx-plugin, can be found here: http://jsfiddle.net/z4JPB/1/
It currently appears to me that a possible solution could work like this:
appendChild
,replaceChild
andinsertBefore
- this has to happen before the content-script from the chrome-extension is executed.DOMNodeInsertedIntoDocument
andDOMNodeInserted
events看来,该插件仅在
video
标记中存在src
元素时才替换视频。对我来说,它的工作原理是首先添加video
标签,然后在第二个线程中添加src
标签。然而,这在 IE 中不起作用,但 IE 一次插入完整的视频标签没有问题。因此,以下代码在所有浏览器中都适用于我(当然,需要 jQuery):
It seems, that the plugin is only replacing the video when there are
src
elements within thevideo
tag. For me it worked by first adding thevideo
tag, and then - in a second thread - add thesrc
tags. However, this doesn´t work in IE but IE had no problem with an insertion of the complete video tag at once.So following code worked for me in all browsers (of course, jQuery required):