🏠 Home 

虎扑(hupu.com)热帖高亮

回复大于150,浏览大于5000的帖子自动背景加红,字体加粗效果


Install this script?
  1. // ==UserScript==
  2. // @name 虎扑(hupu.com)热帖高亮
  3. // @namespace tyshengsx@gmail.com
  4. // @version 0.1
  5. // @grant none
  6. // @include http://bbs.hupu.com/*
  7. // @description 回复大于150,浏览大于5000的帖子自动背景加红,字体加粗效果
  8. // ==/UserScript==
  9. var allpres, thispre;
  10. allpres = document.evaluate(
  11. "//table[@id='ajaxtable']//td[@class='smalltxt']",
  12. document,
  13. null,
  14. XPathR###lt.UNORDERED_NODE_SNAPSHOT_TYPE,
  15. null);
  16. if (allpres.snapshotLength == 0) {
  17. allpres = document.evaluate(
  18. "//table[@id='pl']//td[@class='p_re']",
  19. document,
  20. null,
  21. XPathR###lt.UNORDERED_NODE_SNAPSHOT_TYPE,
  22. null);
  23. }
  24. var reg_pre = new RegExp(/([0-9]{4,}|1{1}[5-9]{1}[0-9]{1,}|[2-9]{1}[0-9]{2,})(\s\/\s)([0-9]{5,}|[5-9]{1}[0-9]{3,})/);
  25. for (var i = 0; i < allpres.snapshotLength; i++) {
  26. thispre = allpres.snapshotItem(i);
  27. // 使用 thispre
  28. var html = thispre.innerHTML;
  29. if(reg_pre.test(html)){
  30. thispre.parentNode.style.backgroundColor = '#FFA07A';
  31. thispre.parentNode.style.fontWeight = "bold";
  32. }
  33. }