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

Add a horizontal scrollbar to the div container of multi programming language Code

As of 13/01/2024. See the latest version.

  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.2.2
  7. // @description:en Add a horizontal scrollbar to the div container of multi programming language Code
  8. // @description:zh-tw 在多程式設計語言Code的div容器中添加一個水准滾動條
  9. // @description Add a horizontal scrollbar to the div container of multi programming language Code
  10. // @author aspen138
  11. // @match https://leetcode.cn/*
  12. // @match https://leetcode.com/*
  13. // @grant none
  14. // @license MIT
  15. // ==/UserScript==
  16.  
  17.  
  18.  
  19.  
  20. (function() {
  21. 'use strict';
  22.  
  23. // Add your JavaScript code here
  24. var css = `
  25. .flex.select-none.bg-layer-2:not(.dark) {
  26. overflow-x: auto; /* Trigger horizontal scrolling */
  27. display: flex; /* Ensure the items are in a flex row */
  28. white-space: nowrap; /* Prevent wrapping of items */
  29. }
  30. .flex.select-none.bg-layer-2:not(.dark) > div {
  31. flex: 0 0 auto; /* Prevent flex items from shrinking */
  32. display: inline-block; /* Treat each div as an inline block */
  33. }
  34. /* Styles for dark mode */
  35. .flex.select-none.bg-layer-2.dark.bg-dark-layer-2 {
  36. overflow-x: auto; /* Trigger horizontal scrolling for dark mode */
  37. display: flex; /* Ensure the items are in a flex row for dark mode */
  38. white-space: nowrap; /* Prevent wrapping of items for dark mode */
  39. }
  40. .flex.select-none.bg-layer-2.dark.bg-dark-layer-2 > div {
  41. flex: 0 0 auto; /* Prevent flex items from shrinking in dark mode */
  42. display: inline-block; /* Treat each div as an inline block in dark mode */
  43. }
  44. `;
  45.  
  46. // Create a style element
  47. var style = document.createElement('style');
  48. style.type = 'text/css';
  49. style.appendChild(document.createTextNode(css));
  50. document.head.appendChild(style);
  51. })();