• 一款好用的leetcode周赛插件:再也不用写代码的时候来回看描述了


    今天发现了一个群友分享的一款leetcode插件,分享给大家。

    对于熟悉leetcode的小伙伴应该会有一个困扰,那就是在leetcode打周赛的时候,题目描述和编辑区不是左右排版的,而是上下排版的,我们代码写着写着就需要移到最上方再看一下题目描述。如下图所示

    在这里插入图片描述

    使用这款插件后我们就是下面这样的,这样我们就可以不用来回上下移动了
    在这里插入图片描述

    使用步骤

    1.在浏览器端下载油猴TamperMonkey

    2.进入浏览器扩展程序,找到油猴

    在这里插入图片描述

    3.在油猴中放入这个脚本

    在这里插入图片描述

    就可以啦,然后竞赛页面就会变成上面那样啦

    脚本源代码如下

    https://paste.nugine.xyz/yzex544a

    // ==UserScript==
    // @name         Better Contest Page
    // @namespace    http://tampermonkey.net/
    // @version      0.0.2
    // @description  better contest page
    // @author       ExplodingKonjac
    // @license      GPLv3
    // @match        https://leetcode.cn/contest/*/problems/*
    // @match        https://leetcode.com/contest/*/problems/*
    // ==/UserScript==
    
    const CSS = `
    body {
      display: flex;
      flex-direction: column;
    }
    
    body .content-wrapper {
      height: 0;
      min-height: 0 !important;
      flex: 1;
      display: flex;
      flex-direction: column;
      padding-bottom: 0 !important;
    }
    
    .content-wrapper #base_content {
      display: flex;
      overflow: hidden;
      height: 0;
      flex: 1;
    }
    
    .content-wrapper #base_content > .container {
      width: 40%;
      overflow: scroll;
    }
    
    .content-wrapper #base_content > .container .question-content {
      overflow: unset !important;
    }
    
    .content-wrapper #base_content > .editor-container {
      flex: 1;
      overflow: scroll;
    }
    
    .content-wrapper #base_content > .editor-container .container {
      width: 100% !important;
    }
    
    .content-wrapper #base_content > .custom-resize {
      width: 4px;
      height: 100%;
      background: #eee;
      cursor: ew-resize;
      margin: 0 2px;
    }
    
    .content-wrapper #base_content > .custom-resize:hover {
      background: #1a90ff;
    }
    `
    
    const storageKey = '--previous-editor-size'
    
    ;(function () {
      const $css = document.createElement('style')
      $css.innerHTML = CSS
      document.head.append($css)
      const $problem = document.querySelector('.content-wrapper #base_content > .container')
      const $editor = document.querySelector('.content-wrapper #base_content > .editor-container')
      const $resize = document.createElement('div')
      if (localStorage.getItem(storageKey)) {
        $problem.style.width = localStorage.getItem(storageKey)
      }
      $editor.parentElement.insertBefore($resize, $editor)
      $resize.classList.add('custom-resize')
      let currentSize, startX, resizing = false
      $resize.addEventListener('mousedown', (e) => {
        currentSize = $problem.getBoundingClientRect().width
        startX = e.clientX
        resizing = true
        $resize.style.background = '#1a90ff'
      })
      window.addEventListener('mousemove', (e) => {
        if (!resizing) return
        const deltaX = e.clientX - startX
        const newSize = Math.max(450, Math.min(1200, currentSize + deltaX))
        $problem.style.width = `${newSize}px`
        e.preventDefault()
      })
      window.addEventListener('mouseup', (e) => {
        if (!resizing) return
        e.preventDefault()
        resizing = false
        $resize.style.background = ''
        localStorage.setItem(storageKey, $problem.style.width)
      })
    })()
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
  • 相关阅读:
    笔试强训48天——day16
    栈和队列(8.4)
    1407. 排名靠前的旅行者
    JavaScript内置对象 - Array数组(四)- 序列生成器
    BetaFlight深入传感设计之六:四元数计算方法
    CMake教程(一)
    ESP32-IDF使用I2S驱动MAX98375--解析WAV文件
    关于web前端大作业的HTML网页设计——我的班级网页HTML+CSS+JavaScript
    Apipost现已支持连接数据库!
    sizeof与strlen的区别
  • 原文地址:https://blog.csdn.net/Supreme7/article/details/133756303