summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Dolgov <[email protected]>2021-05-07 15:04:38 +0300
committerAndrew Dolgov <[email protected]>2021-05-07 15:04:38 +0300
commitfa42b26cb19724a2067c925f4ee2d11edad2ea88 (patch)
treebe41c397fdda97121061bcc3bd73a19e39e7384e
initial
-rw-r--r--init.js23
-rw-r--r--init.php23
2 files changed, 46 insertions, 0 deletions
diff --git a/init.js b/init.js
new file mode 100644
index 0000000..c7c1138
--- /dev/null
+++ b/init.js
@@ -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;
+ }
+
+}