summaryrefslogtreecommitdiff
path: root/plugins/af_zz_noautoplay/init.js
blob: 9b7bf00772cc1e1c97ae000160ea4112bb7beb23 (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
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;
	});

});