From a0b020cdc7c14c7eb41130d51f11036c1cac6fde Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Fri, 5 Mar 2021 10:16:21 +0300 Subject: initial --- init.js | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 init.js (limited to 'init.js') diff --git a/init.js b/init.js new file mode 100644 index 0000000..28e7ec7 --- /dev/null +++ b/init.js @@ -0,0 +1,41 @@ +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + ready(function () { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { + if (row) { + console.log("af_zz_noautoplay!"); + console.log(row); + + const videos = row.getElementsByTagName("video"); + console.log(row.innerHTML); + + for (i = 0; i < videos.length; i++) { + + videos[i].removeAttribute("autoplay"); + videos[i].pause(); + videos[i].onclick = function () { + this.paused ? this.play() : this.pause(); + } + } + } + + return true; + }); + + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) { + if (row) { + const videos = row.getElementsByTagName("video"); + + for (i = 0; i < videos.length; i++) { + videos[i].removeAttribute("autoplay"); + videos[i].pause(); + videos[i].onclick = function () { + this.paused ? this.play() : this.pause(); + } + } + + } + + return true; + }); + }); +}); -- cgit v1.2.3