From: Andrew Dolgov Date: Fri, 31 Jul 2015 10:42:22 +0000 (+0300) Subject: add af_zz_noautoplay plugin X-Git-Tag: 16.3~196^2~2 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=1dbc8d6062e3784cc9fe0637c70f461a2047af2e;p=tt-rss.git add af_zz_noautoplay plugin --- diff --git a/plugins/af_zz_noautoplay/init.js b/plugins/af_zz_noautoplay/init.js new file mode 100644 index 00000000..9b7bf007 --- /dev/null +++ b/plugins/af_zz_noautoplay/init.js @@ -0,0 +1,40 @@ +dojo.addOnLoad(function() { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function(row) { + if (row) { + console.log("af_zz_noautoplay!"); + console.log(row); + + var 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) { + var 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; + }); + +}); \ No newline at end of file diff --git a/plugins/af_zz_noautoplay/init.php b/plugins/af_zz_noautoplay/init.php new file mode 100644 index 00000000..a36dafa9 --- /dev/null +++ b/plugins/af_zz_noautoplay/init.php @@ -0,0 +1,24 @@ +host = $host; + } + + function get_js() { + return file_get_contents(__DIR__ . "/init.js"); + } + + function api_version() { + return 2; + } + +} +?>