diff options
author | Andrew Dolgov <[email protected]> | 2021-03-05 10:16:21 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-03-05 10:16:21 +0300 |
commit | a0b020cdc7c14c7eb41130d51f11036c1cac6fde (patch) | |
tree | 753e89281b7bf4b9b80b1b68dee9774eacd8dce5 |
initial
-rw-r--r-- | init.js | 41 | ||||
-rw-r--r-- | init.php | 23 |
2 files changed, 64 insertions, 0 deletions
@@ -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; + }); + }); +}); diff --git a/init.php b/init.php new file mode 100644 index 0000000..505f9fc --- /dev/null +++ b/init.php @@ -0,0 +1,23 @@ +<?php +class Af_Zz_NoAutoPlay extends Plugin { + private $host; + + function about() { + return array(null, + "Don't autoplay HTML5 videos", + "fox"); + } + + function init($host) { + $this->host = $host; + } + + function get_js() { + return file_get_contents(__DIR__ . "/init.js"); + } + + function api_version() { + return 2; + } + +}
\ No newline at end of file |