Greasy Fork 还支持 简体中文。

Hi, Confluence 🚀

行内代码添加高亮样式;支持快捷访问‘页面信息’。作者是在 Confluence 7.13.3 编写和应用,其它版本可能需要调整源码。另外,需要调整域名匹配规则。

  1. // ==UserScript==
  2. // @name Hi, Confluence 🚀
  3. // @namespace https://xinlu.ink/
  4. // @version 1.0.0
  5. // @description 行内代码添加高亮样式;支持快捷访问‘页面信息’。作者是在 Confluence 7.13.3 编写和应用,其它版本可能需要调整源码。另外,需要调整域名匹配规则。
  6. // @author Nicholas Hsiang
  7. // @icon https://www.feature.com/favicon.ico
  8. // @match *://wiki.feature-inc.cn/*
  9. // @grant GM_addStyle
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function () {
  14. 'use strict';
  15.  
  16. /**
  17. * 🚀 Highlight inline code
  18. */
  19.  
  20. function addClassName() {
  21. const preEles = [
  22. ...document.querySelectorAll('p > code'),
  23. ...document.querySelectorAll('li > code'),
  24. ];
  25.  
  26. preEles.forEach((tiem) => {
  27. tiem.classList.add('__x-code__');
  28. });
  29. }
  30.  
  31. function createStyleSheet() {
  32. const style = `
  33. .__x-code__ {
  34. padding: .2em .4em;
  35. margin: 0;
  36. white-space: break-spaces;
  37. background-color: rgba(175, 184, 193, 0.25);
  38. border-radius: 6px;
  39. }
  40.  
  41. .wiki-content ul li { line-height: 1.6; }
  42. `;
  43.  
  44. GM_addStyle(style);
  45. }
  46.  
  47. createStyleSheet();
  48. addClassName();
  49.  
  50. /**
  51. * 🚀 快捷功能
  52. */
  53. function keyboardShortcut(event) {
  54. // 在 macOS 上,Option (ALT) 键有特殊功能,它用于输入特殊字符和符号。
  55. // 按下 Option+T 时,macOS 可能将其解释为一个特殊字符输入,而不是单纯的修饰键+字母组合,
  56. // 这就导致 JavaScript 事件系统接收到的不是标准的按键事件,而是 "Unidentified"。
  57. // event.code 表示物理按键的位置,与键盘布局无关。
  58.  
  59. // 按 ALT+I 查看页面信息
  60. if (
  61. event.altKey &&
  62. ((event.key === 'Unidentified' && event.code === 'KeyI') ||
  63. event.key.toLowerCase() === 'i')
  64. ) {
  65. return document.querySelector('#view-page-info-link')?.click();
  66. }
  67.  
  68. // 按 ALT+P 查看页面
  69. if (
  70. event.altKey &&
  71. ((event.key === 'Unidentified' && event.code === 'KeyP') ||
  72. event.key.toLowerCase() === 'p')
  73. ) {
  74. return document.querySelector('#viewPageLink')?.click();
  75. }
  76. }
  77.  
  78. function keydown(event) {
  79. keyboardShortcut(event);
  80. }
  81.  
  82. document.addEventListener('keydown', keydown, true);
  83. })();