PTH Upload page save textarea sizes

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

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         PTH Upload page save textarea sizes
// @version      0.2
// @description  Save the sizes of the textareas when you change them, and then set them back on page load
// @author       Chameleon
// @include      http*://redacted.ch/upload.php*
// @grant        none
// @namespace https://greasyfork.org/users/87476
// ==/UserScript==

(function() {
  'use strict';

  var sizes=window.localStorage.uploadPageTextareaSizes;
  if(!sizes)
  {
    sizes=[[503, 126], [503, 126]];
  }
  else
    sizes=JSON.parse(sizes);
  
  var album=document.getElementById('album_desc');
  album.setAttribute('style', 'width: '+sizes[0][0]+'px; height: '+sizes[0][1]+'px');
  var release=document.getElementById('release_desc');
  release.setAttribute('style', 'width: '+sizes[1][0]+'px; height: '+sizes[1][1]+'px');
  release.addEventListener('mouseup', resized.bind(undefined, album, release), false);
  album.addEventListener('mouseup', resized.bind(undefined, album, release), false);
})();

function resized(album, release)
{
  window.localStorage.uploadPageTextareaSizes = JSON.stringify([[album.clientWidth, album.clientHeight], [release.clientWidth, release.clientHeight]]);
}