add af_zz_noautoplay plugin
This commit is contained in:
parent
d8e8e24e34
commit
1dbc8d6062
2 changed files with 64 additions and 0 deletions
40
plugins/af_zz_noautoplay/init.js
Normal file
40
plugins/af_zz_noautoplay/init.js
Normal file
|
@ -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;
|
||||
});
|
||||
|
||||
});
|
24
plugins/af_zz_noautoplay/init.php
Normal file
24
plugins/af_zz_noautoplay/init.php
Normal file
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
class Af_Zz_NoAutoPlay extends Plugin {
|
||||
private $host;
|
||||
|
||||
function about() {
|
||||
return array(1.0,
|
||||
"Don't autoplay HTML5 videos",
|
||||
"fox");
|
||||
}
|
||||
|
||||
function init($host) {
|
||||
$this->host = $host;
|
||||
}
|
||||
|
||||
function get_js() {
|
||||
return file_get_contents(__DIR__ . "/init.js");
|
||||
}
|
||||
|
||||
function api_version() {
|
||||
return 2;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue