Greasy Fork 支持简体中文。

微信读书划线自动高亮

微信读书划线自动高亮(没了)

  1. // ==UserScript==
  2. // @name 微信读书划线自动高亮
  3. // @description 微信读书划线自动高亮(没了)
  4. // @namespace http://tampermonkey.net/
  5. // @version 0.1
  6. // @description try to take over the world!
  7. // @author You
  8. // @match https://weread.qq.com/web/reader/*
  9. // @icon https://www.google.com/s2/favicons?sz=64&domain=qq.com
  10. // @grant none
  11. // @license MIT
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. const path = "#routerView > div.app_content > div.readerChapterContent.fontLevel1 > div.renderTargetContainer > div.reader_toolbar_container > div > div > button.toolbarItem.underlineBg"
  17. var element = document.querySelector(path);
  18. var hintCnt = 0
  19. function checkElement() {
  20. console.log("hintCnt:"+hintCnt)
  21. element = document.querySelector(path);
  22. if (element) {
  23. if(!isElementVisible(element)){
  24. hintCnt = 0
  25. }
  26. else{
  27. if(hintCnt!=0) return
  28. hintCnt++
  29. element.click();
  30. }
  31. }
  32. }
  33.  
  34. function isElementVisible(element) {
  35. return element.offsetParent !== null;
  36. }
  37.  
  38. // 设置轮询时间间隔(单位:毫秒)
  39. const interval = 100
  40.  
  41. // 开始轮询
  42. setInterval(checkElement, interval);
  43. })();