i-Comic 爱动漫 bug 修复/允许全屏

1.允许googlevideo全屏 2.修复宽度小于约600px后播放窗口无法点击的bug

  1. // ==UserScript==
  2. // @name i-Comic Player Page Bug Fix / Allow fullscreen
  3. // @name:zh-CN i-Comic 爱动漫 bug 修复/允许全屏
  4. // @name:zh-TW i-Comic 愛動漫 bug 修複/允許全屏
  5. // @namespace http://tampermonkey.net/
  6. // @version 0.5
  7. // @description Fixes misc bugs, allow fullscreen for googlevideo
  8. // @description:zh-CN 1.允许googlevideo全屏 2.修复宽度小于约600px后播放窗口无法点击的bug
  9. // @description:zh-TW 1.允許googlevideo全屏 2.修複寬度小于約600px後播放窗口無法點擊的bug
  10. // @author Yifan Gu
  11. // @match http://www.i-comic.net/anime/*
  12. // @grant none
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17. function getElementByXpath(path) {
  18. return document.evaluate(path, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
  19. }
  20. var playerContainer = getElementByXpath('/html/body/div[2]');
  21. var oldContainerStyle = playerContainer.getAttribute('style');
  22. oldContainerStyle = oldContainerStyle ? oldContainerStyle : '';
  23. var newContainerStyle = oldContainerStyle + ' z-index: 100;';
  24. playerContainer.setAttribute('style', newContainerStyle);
  25. //fix body padding
  26. var body = document.getElementsByTagName('body')[0];
  27. var oldBodyStyle = body.getAttribute('style');
  28. oldBodyStyle = oldBodyStyle ? oldBodyStyle : '';
  29. var newBodyStyle = oldBodyStyle + ' padding-top: 50px;';
  30. body.setAttribute('style', newBodyStyle);
  31. //allowfullscreen
  32. var vid = document.getElementById('player');
  33. function onChange () {
  34. var iframes = vid.getElementsByTagName('iframe');
  35. for (var i = 0; i < iframes.length; i++) {
  36. if (iframes[i].allowFullscreen !== true) {
  37. iframes[i].allowFullscreen = true;
  38. }
  39. }
  40. }
  41. vid.addEventListener('DOMSubtreeModified', onChange, false);
  42. onChange();
  43. })();