line

add line

  1. // ==UserScript==
  2. // @name line
  3. // @include *
  4. // @supportURL https://github.com/sxlgkxk/browser_script/issues
  5. // @version 0.2
  6. // @description add line
  7. // @namespace http://sxlgkxk.github.io/
  8. // @author sxlgkxk
  9. // @icon http://sxlgkxk.github.io/im/avatar.jpg
  10. // @license MIT
  11. // @grant GM_getValue
  12. // @grant GM_setValue
  13. // @grant GM_xmlhttpRequest
  14. // ==/UserScript==
  15.  
  16. (function () {
  17.  
  18. //-------------------------------- common functions --------------------------------
  19.  
  20. function addScript(src) {
  21. var scripts_dom = document.createElement('script');
  22. scripts_dom.src = src;
  23. scripts_dom.type = 'text/javascript';
  24. document.getElementsByTagName('head')[0].appendChild(scripts_dom);
  25. }
  26.  
  27. function addStyle(html) {
  28. style = document.createElement("div")
  29. document.body.before(style)
  30. style.innerHTML = `<style>` + html + `</style>`
  31. }
  32.  
  33. //-------------------------------- code snippets --------------------------------
  34.  
  35. addStyle(`
  36. #line_button{
  37. color: #fff;
  38. background-color: #000;
  39. border-radius: 5px;
  40. position: fixed;
  41. right: 10px;
  42. width: 50px;
  43. top: ${document.documentElement["scrollTop"]+window.innerHeight*0.5-25+'px'};
  44. height: 50px;
  45. z-index: 99999;
  46. }
  47. `)
  48.  
  49. //-------------------------------- line dom --------------------------------
  50.  
  51. body = document.querySelector('body')
  52. container = document.createElement('div')
  53. container.innerHTML = `
  54. <button id="line_button" onclick="document.addLine()">line</button>
  55. `
  56. document.body.before(container)
  57.  
  58. function addLine(){
  59. let line_dom = document.createElement('div')
  60. line_dom.style.position = 'absolute'
  61. line_dom.style.top = document.documentElement["scrollTop"]+window.innerHeight*0.5+'px'
  62. line_dom.style.left = '0'
  63. line_dom.style.width = '100%'
  64. line_dom.style.height= '3px'
  65. line_dom.style.backgroundColor = '#f00'
  66. line_dom.style.zIndex = '999999'
  67. console.log(line_dom)
  68. document.body.appendChild(line_dom)
  69. }
  70. document.addLine = addLine
  71.  
  72. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址