Wide-ish PhotoPea.com

17.02.2020, 10:33:05, Please do tell me if you know how to resize PhotoPea's canvas without wisible stretching!

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name        Wide-ish PhotoPea.com
// @namespace   Violentmonkey Scripts
// @match       https://www.photopea.com/
// @grant       none
// @version     1.0
// @author      UniBreakfast
// @description 17.02.2020, 10:33:05, Please do tell me if you know how to resize PhotoPea's canvas without wisible stretching!
// ==/UserScript==
const qSel = sel => document.querySelector(sel)
const inter = setInterval(()=> {
  const canvas = qSel('canvas')
  if (!canvas) return
  clearInterval(inter)
  canvas.style.margin = 'auto'
  canvas.parentNode.addEventListener('mousemove', e => {
    qSel('.photopea').lastChild.style.display = 'none'
    const width = innerWidth - document.querySelector('.rightbar').clientWidth - document.querySelector('.sbar').clientWidth - 30
    // canvas.height =  width / canvas.width * canvas.height
    // canvas.width = width
    qSel('.panelhead').style.maxWidth = qSel('.pbody').parentNode.style.width = /*canvas.style.width =*/ width+'px'
    // canvas.style.height = canvas.height+'px'
  })
}, 500)