PTH Upload page save textarea sizes

Save the sizes of the textareas when you change them, and then set them back on page load

  1. // ==UserScript==
  2. // @name PTH Upload page save textarea sizes
  3. // @version 0.2
  4. // @description Save the sizes of the textareas when you change them, and then set them back on page load
  5. // @author Chameleon
  6. // @include http*://redacted.ch/upload.php*
  7. // @grant none
  8. // @namespace https://greasyfork.org/users/87476
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13.  
  14. var sizes=window.localStorage.uploadPageTextareaSizes;
  15. if(!sizes)
  16. {
  17. sizes=[[503, 126], [503, 126]];
  18. }
  19. else
  20. sizes=JSON.parse(sizes);
  21. var album=document.getElementById('album_desc');
  22. album.setAttribute('style', 'width: '+sizes[0][0]+'px; height: '+sizes[0][1]+'px');
  23. var release=document.getElementById('release_desc');
  24. release.setAttribute('style', 'width: '+sizes[1][0]+'px; height: '+sizes[1][1]+'px');
  25. release.addEventListener('mouseup', resized.bind(undefined, album, release), false);
  26. album.addEventListener('mouseup', resized.bind(undefined, album, release), false);
  27. })();
  28.  
  29. function resized(album, release)
  30. {
  31. window.localStorage.uploadPageTextareaSizes = JSON.stringify([[album.clientWidth, album.clientHeight], [release.clientWidth, release.clientHeight]]);
  32. }