Bangumi: Highlight ep#

Highlight Episode Number

Verze ze dne 19. 05. 2017. Zobrazit nejnovější verzi.

K instalaci tototo skriptu si budete muset nainstalovat rozšíření jako Tampermonkey, Greasemonkey nebo Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Violentmonkey.

K instalaci tohoto skriptu si budete muset nainstalovat rozšíření jako Tampermonkey nebo Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

K instalaci tohoto skriptu si budete muset nainstalovat manažer uživatelských skriptů.

(Už mám manažer uživatelských skriptů, nechte mě ho nainstalovat!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Už mám manažer uživatelských stylů, nechte mě ho nainstalovat!)

// ==UserScript==
// @name         Bangumi: Highlight ep#
// @namespace    moe.bangumi.hightlight-episode
// @version      0.12
// @description  Highlight Episode Number
// @author       Willian
// @match        https://bangumi.moe/*
// @grant        unsafeWindow
// @run-at       document-end
// ==/UserScript==

const $ = unsafeWindow.$;
const angular = unsafeWindow.angular;

// let rin = angular.module('rin')
// rin['_invokeQueue'].forEach(function(value){ 
//     console.log(value[1] + ": " + value[2][0]);
// })
// rin.directive('torrentList',(e)=>{

// })

const colors = [
    "#FF0097",
    "#A200FF",
    "#00ABA9",
    "#8CBF26",
    "#E671B8",
    "#F09609",
    "#1BA1E2"
];
const epRegex = /((.+)([\s|\[|【|第]))(\d{1,3}(?:[-|~]\d{1,3})?)(([集|話|话|\s|\]|】])(.*))/;

const highlightMe = function(){
    let $element = $(this);
    if($element.html().match(/<highlight/)){
        return;
    }
    debugger
    var text = $element.text().trim();
    var found = epRegex.exec(text);
    if(found !== null){
        let ep = Number(found[4]) >-1 ? Number(found[4]) : 0;
        let color = colors[ep % colors.length];
        $element.empty().append([
            document.createTextNode(found[1]),
            `<highlight style="background-color: ${color}">${found[4]}</highlight>`,
            document.createTextNode(found[5])
        ]);
    }else{
        console.log(text);
    }
};
$(document).on("mouseenter",'[torrent-list]',function(e){
    let titleElements = $(this).find(".md-item-raised-title");

    titleElements.find("span").each(highlightMe);
    titleElements.find("span").each(highlightMe);
    titleElements.off("mouseenter");
    titleElements.on("mouseenter",highlightMe);
});
// $(document).on("mouseover",'.compact-torrent-list',function(e){
//     console.log(this)
// })