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.4
  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 found = epRegex.exec($element.text());
  40. if(found !== null){
  41. let ep = Number(found[3]) >-1 ? Number(found[4]) : 0;
  42. let color = colors[ep % colors.length];
  43. $element.empty().append([
  44. document.createTextNode(found[1]),
  45. `<highlight style="background-color: ${color}">${found[4]}</highlight>`,
  46. document.createTextNode(found[5])
  47. ]);
  48. }else{
  49. console.log($element.text())
  50. }
  51. }
  52. $(document).on("mouseenter",'[torrent-list]',function(e){
  53. let titleElements = $(this).find(".md-item-raised-title");
  54.  
  55. titleElements.find("span").each(highlightMe);
  56. titleElements.off("mouseenter");
  57. titleElements.on("mouseenter",highlightMe);
  58. titleElements.find("span").each(highlightMe);
  59. });
  60. // $(document).on("mouseover",'.compact-torrent-list',function(e){
  61. // console.log(this)
  62. // })

QingJ © 2025

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