NGA Missing Floor Detector

自动检测NGA楼层缺失

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==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('没有匹配,请尝试刷新')
    }
})();