diff options
author | Andrew Dolgov <[email protected]> | 2021-05-07 15:04:38 +0300 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2021-05-07 15:04:38 +0300 |
commit | fa42b26cb19724a2067c925f4ee2d11edad2ea88 (patch) | |
tree | be41c397fdda97121061bcc3bd73a19e39e7384e |
initial
-rw-r--r-- | init.js | 23 | ||||
-rw-r--r-- | init.php | 23 |
2 files changed, 46 insertions, 0 deletions
@@ -0,0 +1,23 @@ +/* global require, PluginHost */ + +require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) { + function unpreload(vid) { + vid.setAttribute("preload", "none"); + } + + function unpreload_all(row) { + [...row.querySelectorAll("video")].forEach((vid) => unpreload(vid)); + } + + ready(function () { + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) { + unpreload_all(row); + return true; + }); + + PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) { + unpreload_all(row); + return true; + }); + }); +}); diff --git a/init.php b/init.php new file mode 100644 index 0000000..89d51eb --- /dev/null +++ b/init.php @@ -0,0 +1,23 @@ +<?php +class Af_Zz_NoPreload extends Plugin { + private $host; + + function about() { + return array(null, + "Don't preload HTML5 videos (for slow connections)", + "fox"); + } + + function init($host) { + $this->host = $host; + } + + function get_js() { + return file_get_contents(__DIR__ . "/init.js"); + } + + function api_version() { + return 2; + } + +} |