NGA Missing Floor Detector

自动检测NGA楼层缺失

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

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

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

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

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

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.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         NGA Missing Floor Detector
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  自动检测NGA楼层缺失
// @author       东云曦月
// @match        https://bbs.nga.cn/read.php*
// @icon         https://img4.nga.178.com/ngabbs/post/smile/pg04.png
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    var body = document.body.innerHTML
    var patt = /a name=.l\d+./g
    var floors = body.match(patt)
    if (floors != null){
        //alert('楼层数:' + floors.length)
        var app = new Array()
        var min = 10000000;
        for (var i = 0; i < floors.length; i++){
            //alert(floors[i])
            var num_str = floors[i].match(/\d+/g)
            //alert(num_str)
            var index = parseInt(num_str)
            if (app.length == 0 || app.indexOf(index) == -1){
                app.push(index)
                if (index < min){
                    min = index;
                }
                //alert('!')
            }
        }
        //alert(app)
        min = min / 20 * 20
        var missing = new Array()
        for (i = min; i < min + 20; i++){
            if (app.indexOf(i) == -1){
                missing.push(i)
            }
        }
        if (missing.length == 0){
            alert('无缺失楼层')
        }
        else{
            alert('缺失以下楼层:' + missing)
        }
    }
    else {
        alert('没有匹配,请尝试刷新')
    }
})();