给 p5js.org 加分段

2022/4/18 12:38:58

  1. // ==UserScript==
  2. // @name 给 p5js.org 加分段
  3. // @namespace leizingyiu.net
  4. // @match http*://p5js.org/*
  5. // @grant none
  6. // @version 0.0.1
  7. // @author leizingyiu
  8. // @description 2022/4/18 12:38:58
  9. // @license GNU AGPLv3
  10. // ==/UserScript==
  11.  
  12.  
  13. function yiu_styling_p5js_org(){
  14. [...document.querySelectorAll('p')].map(p=>{
  15. p.innerHTML=p.innerHTML.replace(/(•)/g,`<span class='yiu_br'></span>$1`);
  16. });
  17.  
  18. var style_id='yiu_style';
  19. var style_innerHTML=`
  20. .yiu_br{
  21. height:1em;
  22. width:100%;
  23. display:block;
  24. }
  25. p{
  26. border-top: solid 1px #eee;
  27. margin-top: 1em;
  28. }
  29. .paramtype p {
  30. border-top: initial;
  31. margin-top: initial;
  32. }
  33. .paramtype p em{
  34. display:block;
  35. margin-top:1em;
  36. }
  37. .paramname{
  38. max-width: 25%;
  39. }
  40. `;
  41.  
  42. if(document.getElementById(style_id)){
  43. document.getElementById(style_id).innerHTML=style_innerHTML;
  44. }else{
  45. let style=document.createElement('style');
  46. style.id=style_id;
  47. style.innerHTML=style_innerHTML;
  48. document.head.appendChild(style);
  49. }
  50. }
  51.  
  52. if(document.body){
  53. main=String(yiu_styling_p5js_org);
  54. window.addEventListener('load',()=>{
  55. setTimeout("eval('('+main+')()')",500);
  56. });
  57. }
  58.  
  59.