CSS

  1. (function()
  2. {
  3. "use strict";
  4. setTimeout(function()
  5. {
  6. //alert("设置按键")
  7. var buttonExport = document.createElement("button"); //创建一个按钮
  8. buttonExport.textContent = "导出"; //按钮内容
  9. buttonExport.style.width = '66px'; //按钮宽度
  10. buttonExport.style.height = '32px'; //按钮高度
  11. buttonExport.style.color = '#130c0e'; //按钮文字颜色
  12. buttonExport.style.background = '#d7134566'; //按钮底色
  13. buttonExport.style.borderRadius = '6px'; //按钮四个角弧度
  14. buttonExport.style.border = '3px none';
  15. var strURL = window.location.href;
  16. var strURL_Export
  17. var nameClass
  18. var eleButton
  19. var arrElementsByClassName
  20. //浏览页面的“…”元素名
  21. var strClassNameInView = "favor-wrapper"
  22. //alert("浏览页面")
  23. arrElementsByClassName = document.getElementsByClassName(strClassNameInView)
  24. var lenArr = arrElementsByClassName.length
  25. debugger
  26. if (lenArr)
  27. {
  28. eleButton = arrElementsByClassName[0];
  29. }
  30. else
  31. {
  32. alert("未找到指定类名,请检查是否类名被修改")
  33. //eleButton = document.getElementsByClassName("header-action-item header-action-item-more")[0];
  34. }
  35. eleButton.appendChild(buttonExport);
  36. //alert("已添加按键")
  37. buttonExport.onclick = function ()
  38. {
  39. //alert("绑定按键点击功能")
  40. //strURL_Export = strURL + "/markdown?attachment=true&latexcode=false&anchor=true&linebreak=true"
  41. //window.open(strURL_Export);
  42. };
  43. },2000)//2秒后执行
  44. })();
  45. })}})(that.context, that.fapply, that.console);
  46. //# sourceURL=chrome-extension://iikmkjmpaadaobahmlepeloendndfphd/userscript.html?name=YYYHC.user.js&id=069a07f5-e48f-46bd-87f5-0b7949a9bff9
  47. })((()=>{const k="__u__2221943.7801965578",r=this[k];delete this[k];return r;})())

button

<举个例子>

  1. var buttonExport = document.createElement("button"); //创建一个按钮
  2. buttonExport.textContent = "导出"; //按钮内容
  3. buttonExport.style.width = '66px'; //按钮宽度
  4. buttonExport.style.height = '32px'; //按钮高度
  5. buttonExport.style.color = 'white'; //按钮文字颜色
  6. buttonExport.style.background = 'purple'; //按钮底色
  7. buttonExport.style.borderRadius = '6px'; //按钮四个角弧度
  8. buttonExport.style.border = '0px none'; //去边框

颜色问题

通过颜色名

  1. buttonExport.style.color = 'white'; //按钮文字颜色
  2. buttonExport.style.background = 'purple'; //按钮底色

十六进制

  1. buttonExport.style.color = '#000000'; //按钮文字颜色
  2. buttonExport.style.background = '#00F5FF'; //按钮底色

透明度

透明度十六进制表示法

  • 100-FF
  • 95-F2
  • 90-E6
  • 85-D9
  • 80-CC
  • 75-BF
  • 70-B3
  • 65-A6
  • 60-99
  • 55-8C
  • 50-80
  • 45-73
  • 40-66
  • 35-59
  • 30-4D
  • 25-40
  • 20-33
  • 15-26
  • 10-1A
  • 5-0D
  • 0-00
    1. buttonExport.style.color = '#00000066'; //按钮文字颜
    2. buttonExport.style.background = '#00F5FF66'; //按钮底色
    3. 40%透明度

    通过RGB

    1. buttonExport.style.color = "color:rgb(254,255,255)"; //按钮文字颜色
    2. buttonExport.style.background = "color:rgb(255,255,255)"; //按钮底色

    IF

    1. //alert("浏览页面")
    2. arrElementsByClassName = document.getElementsByClassName(strClassNameInView)
    3. var lenArr = arrElementsByClassName.length
    4. debugger
    5. if (lenArr)
    6. {
    7. eleButton = arrElementsByClassName[0];
    8. }
    9. else
    10. {
    11. alert("未找到指定类名,请检查是否类名被修改")
    12. //eleButton = document.getElementsByClassName("header-action-item header-action-item-more")[0];
    13. }
    IF
    ELSE
    二选一
    当lenArr不为0时
    执行IF
    否则执行ELSE(如图)
    cf6fe6b7da072aeee646c740a477492.png
    //为当前行的代码不执行