您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Change the size of the canvas
当前为
- // ==UserScript==
- // @name Resizable Canvas
- // @namespace Violentmonkey Scripts
- // @match https://sketchful.io/
- // @grant none
- // @version 3
- // @author Bell
- // @description Change the size of the canvas
- // jshint esversion: 6
- // ==/UserScript==
- const maxWidth = '100vw';
- const canvas = document.querySelector('#gameCanvas');
- const gameParent = document.querySelector('.gameParent');
- const header = document.querySelector('.gameHeader');
- const playersList = document.querySelector('#gamePlayersList');
- const innerCanvas = document.querySelector('#canvas');
- const columnRight = document.querySelector('.columnRight');
- const canvasObserver = new MutationObserver(() => {
- if (canvas.style.display !== 'none') {
- gameParent.style.maxWidth = maxWidth;
- gameParent.style.width = localStorage.gameParentWidth || '180vh';
- gameParent.style.resize = 'horizontal';
- }
- else {
- gameParent.style.maxWidth = '';
- gameParent.style.resize = '';
- }
- });
- function onResize() {
- fixHeader();
- if (gameParent.classList.contains('gameParentSettings')) return;
- localStorage.gameParentWidth = gameParent.style.width;
- }
- function fixHeader() {
- const height = gameParent.getBoundingClientRect().height;
- const canvasHeight =
- innerCanvas.getBoundingClientRect().height ||
- columnRight.getBoundingClientRect().height;
- playersList.style.maxHeight = `${canvasHeight}px`;
- if (window.innerHeight - height > 180) header.style.display = '';
- else header.style.display = 'none';
- }
- (function init() {
- header.remove();
- document.querySelector('.game').appendChild(header);
- document.querySelector('.gameContainer').style.marginTop = '0px';
- gameParent.setAttribute('style',
- `overflow: hidden; left: 50%; top: 50%;
- transform: translate(-50%, -50%); position: absolute;
- padding-top: 12px`
- );
- new ResizeObserver(onResize).observe(gameParent);
- canvasObserver.observe(document.querySelector('.game'), { attributes: true });
- canvasObserver.observe(canvas, { attributes: true });
- $('[id^="money"]').remove();
- })();