SplitScreen

split the screen of the page

  1. // ==UserScript==
  2. // @name SplitScreen
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description split the screen of the page
  6. // @author daydreamorama
  7. // @match http://*/*
  8. // @include *://archiveofourown.org/*works/*
  9. // @icon data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. // I stole this from a 2011 script that didn't work anymore.
  14. if (window.top == window) {
  15. /* Get current location */
  16. var loc = window.location + "";
  17.  
  18. /*
  19. * The contents won't be loaded if the location of the iframe is exactly
  20. * the same as the main document (that's probably to protect against
  21. * infinite nesting of iframes), so we need to modify it slightly.
  22. */
  23. if (loc.match(/\?/))
  24. loc = loc.replace(/\?/, '?%20=&');
  25. else
  26. loc = loc + '?';
  27.  
  28.  
  29. document.documentElement.innerHTML = '<head></head>' +
  30. '<body><iframe id="f1"></iframe><iframe id="f2"></iframe>' +
  31. '<div id="ov">&nbsp;</div></body>';
  32.  
  33. var body = document.querySelector('body'), /* Document body */
  34. f1 = document.querySelector('#f1'), /* First iframe */
  35. f2 = document.querySelector('#f2'), /* Second iframe */
  36. ov = document.querySelector('#ov'); /* Overlay */
  37.  
  38. f1.src = f2.src = loc;
  39.  
  40. body.style.margin="0"
  41. body.style.padding="0"
  42. body.style.height="100%"
  43. body.style.width="100%"
  44. body.style.background="#bbb"
  45. body.style.overflow="hidden"
  46.  
  47. f1.style.width="50%"
  48. f1.style.height="100%"
  49. f1.style.border=f2.style.border="none"
  50. f1.style.left="0%"
  51. f1.style.position="absolute"
  52.  
  53.  
  54. f2.style.width="50%"
  55. f2.style.height="100%"
  56. f2.style.left="50%"
  57. f2.style.position="absolute"
  58. // f2.style.borderRight="solid 1px #ddd"
  59.  
  60. ov.style.height="100%"
  61. ov.style.width="100%"
  62. ov.style.position="absolute"
  63. ov.style.zindex="999"
  64. ov.style.display="none"
  65. }
  66.