init.js 956 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. require(['dojo/_base/kernel', 'dojo/ready'], function (dojo, ready) {
  2. ready(function () {
  3. PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED_CDM, function (row) {
  4. if (row) {
  5. console.log("af_zz_noautoplay!");
  6. console.log(row);
  7. var videos = row.getElementsByTagName("video");
  8. console.log(row.innerHTML);
  9. for (i = 0; i < videos.length; i++) {
  10. videos[i].removeAttribute("autoplay");
  11. videos[i].pause();
  12. videos[i].onclick = function () {
  13. this.paused ? this.play() : this.pause();
  14. }
  15. }
  16. }
  17. return true;
  18. });
  19. PluginHost.register(PluginHost.HOOK_ARTICLE_RENDERED, function (row) {
  20. if (row) {
  21. var videos = row.getElementsByTagName("video");
  22. for (i = 0; i < videos.length; i++) {
  23. videos[i].removeAttribute("autoplay");
  24. videos[i].pause();
  25. videos[i].onclick = function () {
  26. this.paused ? this.play() : this.pause();
  27. }
  28. }
  29. }
  30. return true;
  31. });
  32. });
  33. });