Greasy Fork is available in English.

LeetCode显示的多编程语言代码区域增加水平滚动条

Add a horizontal scrollbar to the div container with class 'bg-layer-2'

目前为 2024-01-13 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name LeetCode显示的多编程语言代码区域增加水平滚动条
  3. // @name:zh-TW LeetCode顯示的多程式設計語言程式碼區域新增水准滾動條
  4. // @name:en LeetCode Horizontal Scroll for Multi Programming Language Code Div Container
  5. // @namespace http://tampermonkey.net/
  6. // @version 0.1
  7. // @description:en Add a horizontal scrollbar to the div container with class 'bg-layer-2'
  8. // @description:zh-tw 將水准滾動條添加到類為“bg-layer-2”的div容器中
  9. // @description Add a horizontal scrollbar to the div container with class 'bg-layer-2'
  10. // @author aspen138
  11. // @match https://leetcode.cn/*
  12. // @match https://leetcode.com/*
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17. (function() {
  18. 'use strict';
  19.  
  20. // Add your JavaScript code here
  21. var css = `
  22. .bg-layer-2 {
  23. overflow-x: auto; /* Trigger horizontal scrolling */
  24. display: flex; /* Ensure the items are in a flex row */
  25. white-space: nowrap; /* Prevent wrapping of items */
  26. }
  27. .bg-layer-2 > div {
  28. flex: 0 0 auto; /* Prevent flex items from shrinking */
  29. display: inline-block; /* Treat each div as an inline block */
  30. }
  31. `;
  32.  
  33. // Create a style element
  34. var style = document.createElement('style');
  35. style.type = 'text/css';
  36. style.appendChild(document.createTextNode(css));
  37. document.head.appendChild(style);
  38. })();