Greasy Fork is available in English.

Rickroll Detect

Highlights rickrolls on the WaniKani forums

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Rickroll Detect
// @version      0.2
// @namespace    http://tampermonkey.net/
// @description  Highlights rickrolls on the WaniKani forums
// @author       BIsTheAnswer
// @include      https://community.wanikani.com/*
// @license      MIT; http://opensource.org/licenses/MIT
// @grant        none
// ==/UserScript==

(function() {
    /* global $ */
    /* eslint curly: off */

    'use strict';

    var rickroll_array = [
        'dQw4w9WgXcQ',
        'doEqUhFiQS4',
        'oHg5SJYRHA0'
    ];

    var rickroll_regex = /(https?:\/\/)?(www\.)?youtube\.[a-z]+\/watch\?v=([a-zA-Z0-9]+)([^a-zA-Z0-9].*)?/i;
    var rickroll_regex_short = /(https?:\/\/)?(www\.)?youtu\.be\/([a-zA-Z0-9]+)([^a-zA-Z0-9].*)?/i

    function mark_rickrolls() {
        $('a').filter(function() {
            var regex_result = this.href.match(rickroll_regex);
            if(regex_result == null) {
                regex_result = this.href.match(rickroll_regex_short);
                if(regex_result == null)
                    return false;
            }
            return rickroll_array.includes(regex_result[3]);
        }).css('background-color', 'rgb(255, 0, 0, 0.5)').css('border-bottom', '1px solid rgb(255,0,0,0.5)');
    }

    mark_rickrolls();

    var dom_watch = new MutationObserver(function() {
        mark_rickrolls();
    });
    dom_watch.observe(document.body, {childList: true, subtree: true});
})();