summaryrefslogtreecommitdiff
path: root/init.js
blob: 28e7ec78715d20f8719157c1bc75f7f13ff7de70 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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;
		});
	});
});