Custom GitLab Style

Custom GitLab Style!

目前為 2023-05-22 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Custom GitLab Style
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description Custom GitLab Style!
  6. // @author Sean
  7. // @match http://192.168.0.200/fe3project*
  8. // @icon http://192.168.0.200/assets/favicon-7901bd695fb93edb07975966062049829afb56cf11511236e61bcf425070e36e.png
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15. // 注入样式:改变容器宽度,项目描述多行展示
  16. let injectStyle = ".group-list-tree .group-row-contents .description p { white-space: normal; } .container-limited.limit-container-width { max-width: 1400px } .limit-container-width .info-well {max-width: none;}";
  17.  
  18. injectStyle += ".container-fluid.container-limited.limit-container-width .file-holder.readme-holder.limited-width-container .file-content {max-width: none;}"
  19. // 添加注入样式
  20. let extraStyleElement = document.createElement("style");
  21. extraStyleElement.innerHTML = injectStyle;
  22. document.head.appendChild(extraStyleElement);
  23.  
  24. // 改变列表打开链接方式
  25. let change = false;
  26. let tryTimes = 6;
  27.  
  28. function changeOpenType() {
  29. if(!change && tryTimes > 0){
  30. setTimeout(()=> {
  31. let links = document.querySelectorAll('.description a');
  32. tryTimes--;
  33. if(links.length) {
  34. for(let i = 0, l = links.length; i < l; i++) {
  35. links[i].target = "_blank";
  36. if(i = l - 1) {
  37. change = true;
  38. }
  39. }
  40. } else {
  41. changeOpenType();
  42. }
  43. }, 1000);
  44. }
  45. }
  46.  
  47. window.onload = ()=> {
  48.  
  49. changeOpenType();
  50.  
  51. /*
  52. setTimeout(()=> {
  53. const bd = document.querySelector('body');debugger;
  54. alert(bd);
  55. bd.addEventListener('click', function (event) {
  56. alert(1);
  57. if(event.target.tagName === 'A') { event.preventDefault(); }
  58. });
  59. }, 2000);
  60. */
  61. };
  62.  
  63. })();