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!

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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)