USO - fix editor's page height

Prevent the disappearance of the save button on userstyle.org edit page

  1. // ==UserScript==
  2. // @name USO - fix editor's page height
  3. // @namespace github.com/Procyon-b
  4. // @version 0.9.5
  5. // @description Prevent the disappearance of the save button on userstyle.org edit page
  6. // @author Achernar
  7. // @match https://userstyles.org/d/styles/*/edit
  8. // @match https://userstyles.org/styles/update
  9. // @match https://userstyles.org/d/styles/new
  10. // @grant none
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. "use strict";
  15.  
  16. if (window === top) return;
  17.  
  18. if (!document.head.children.length) return;
  19.  
  20. var TO=0, iframe;
  21.  
  22. parent.document.querySelectorAll('iframe').forEach(function(w) {if (w.contentWindow === window) iframe=w;});
  23. if (!iframe) return;
  24.  
  25. function resizeIframe() {
  26. if (TO) {clearTimeout(TO); TO=0;}
  27. iframe.style.height=document.body.scrollHeight + 150 + 'px';
  28. }
  29.  
  30. const obs = new ResizeObserver(function(e){
  31. if (TO) {clearTimeout(TO);}
  32. TO=setTimeout(resizeIframe,200);
  33. });
  34.  
  35. obs.observe(document.body);
  36.  
  37. })();