Bangumi: Highlight ep#

Highlight Episode Number

当前为 2017-05-11 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Bangumi: Highlight ep#
  3. // @namespace moe.bangumi.hightlight-episode
  4. // @version 0.6
  5. // @description Highlight Episode Number
  6. // @author Willian
  7. // @match https://bangumi.moe/*
  8. // @grant unsafeWindow
  9. // @run-at document-end
  10. // ==/UserScript==
  11.  
  12. const $ = unsafeWindow.$;
  13. const angular = unsafeWindow.angular;
  14.  
  15. // let rin = angular.module('rin')
  16. // rin['_invokeQueue'].forEach(function(value){
  17. // console.log(value[1] + ": " + value[2][0]);
  18. // })
  19. // rin.directive('torrentList',(e)=>{
  20.  
  21. // })
  22.  
  23. const colors = [
  24. "#FF0097",
  25. "#A200FF",
  26. "#00ABA9",
  27. "#8CBF26",
  28. "#E671B8",
  29. "#F09609",
  30. "#1BA1E2"
  31. ];
  32. const epRegex = /((.+)([\s|\[|【|第]))(\d{1,2}(?:[-|~]\d{1,2})?)(([話|话|\s|\]|】])(.*))/g;
  33.  
  34. const highlightMe = function(){
  35. let $element = $(this);
  36. if($element.html().match(/<highlight/g)){
  37. return;
  38. }
  39. let text = $element.text().trim()
  40. let found = epRegex.exec(text);
  41. if(found !== null){
  42. let ep = Number(found[3]) >-1 ? Number(found[4]) : 0;
  43. let color = colors[ep % colors.length];
  44. $element.empty().append([
  45. document.createTextNode(found[1]),
  46. `<highlight style="background-color: ${color}">${found[4]}</highlight>`,
  47. document.createTextNode(found[5])
  48. ]);
  49. }else{
  50. console.log(text)
  51. }
  52. }
  53. $(document).on("mouseenter",'[torrent-list]',function(e){
  54. let titleElements = $(this).find(".md-item-raised-title");
  55.  
  56. titleElements.find("span").each(highlightMe);
  57. titleElements.off("mouseenter");
  58. titleElements.on("mouseenter",highlightMe);
  59. titleElements.find("span").each(highlightMe);
  60. });
  61. // $(document).on("mouseover",'.compact-torrent-list',function(e){
  62. // console.log(this)
  63. // })

QingJ © 2025

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