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.2
  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. /*
  13. Regex:
  14. (.+)([\s|\[|【]第?)(\d{1,2}(?:[-|~]\d{1,2})?)(話?[\s|\]|】])(.+)
  15.  
  16. Test with:
  17. 【DHR動研字幕組&茉語星夢】[櫻花任務_Sakura Quest][03][繁體][720P][MP4]
  18. 【動漫國字幕組】★04月新番[路人女主的養成方法♭][00-01][720P_Hi10P][簡繁外掛][MKV]
  19. 【千夏字幕組】【櫻花任務_Sakura Quest】[第03話][1280X720][MP4_PC&PSV兼容][繁體]​
  20. 【极影字幕社】★4月新番 不正经的魔术讲师与禁忌教典 04 GB 720P MP4
  21. 【極影字幕社】★4月新番 不正經的魔術講師與禁忌教典 04 BIG5 720P MP4
  22. 【千夏字幕組】【重啟咲良田_Sagrada Reset】[第03話][1280x720][MP4_PC&PSV兼容][繁體]
  23. 【幻櫻字幕組】【4月新番】【喧嘩番長 乙女-girl beats boys- Kenka Banchou Otome Girl Beats Boys】【03】【BIG5_MP4】【1280X720】
  24. 【幻樱字幕组】【4月新番】【喧哗番长 乙女-girl beats boys- Kenka Banchou Otome Girl Beats Boys】【03】【GB_MP4】【1280X720】
  25. */
  26. const $ = unsafeWindow.$;
  27. const angular = unsafeWindow.angular;
  28.  
  29. // let rin = angular.module('rin')
  30. // rin['_invokeQueue'].forEach(function(value){
  31. // console.log(value[1] + ": " + value[2][0]);
  32. // })
  33. // rin.directive('torrentList',(e)=>{
  34.  
  35. // })
  36.  
  37. const colors = [
  38. "#FF0097",
  39. "#A200FF",
  40. "#00ABA9",
  41. "#8CBF26",
  42. "#E671B8",
  43. "#F09609",
  44. "#1BA1E2"
  45. ];
  46. const epRegex = /(.+)([\s|\[|【]第?)(\d{1,2}(?:[-|~]\d{1,2})?)([話|话]?[\s|\]|】])(.+)/g;
  47.  
  48. const highlightMe = function(){
  49. let $element = $(this);
  50. if($element.html().match(/<highlight/g)){
  51. return;
  52. }
  53. let found = epRegex.exec($element.text());
  54. if(found){
  55. let ep = Number(found[3]) >-1 ? Number(found[3]) : 0;
  56. let color = colors[ep % colors.length];
  57. console.log(found[1]);
  58. $element.empty().append([
  59. document.createTextNode(found[1]),
  60. found[2],
  61. `<highlight style="background-color: ${color}">${found[3]}</highlight>`,
  62. found[4],
  63. document.createTextNode(found[5])
  64. ]);
  65. }
  66. }
  67. $(document).on("mouseenter",'[torrent-list]',function(e){
  68. let titleElements = $(this).find(".md-item-raised-title");
  69.  
  70. titleElements.find("span").each(highlightMe);
  71. titleElements.off("mouseenter");
  72. titleElements.on("mouseenter",highlightMe);
  73. titleElements.find("span").each(highlightMe);
  74. });
  75. // $(document).on("mouseover",'.compact-torrent-list',function(e){
  76. // console.log(this)
  77. // })

QingJ © 2025

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