91pojie

91 can change the world

// ==UserScript==
// @name         91pojie
// @namespace    http://0xpoker.cn/
// @version      0.7
// @description  91 can change the world
// @author       0xPoker
// @require      https://cdn.bootcss.com/jquery/3.3.1/jquery.min.js
// @require      https://cdn.bootcss.com/jquery-cookie/1.4.1/jquery.cookie.min.js
// @require      https://greasyfork.org/scripts/377514-layer-js%E5%A4%87%E4%BB%BD/code/layerjs%E5%A4%87%E4%BB%BD.js?version=668622
// @require      https://cdn.jsdelivr.net/npm/leancloud-storage@3.11.1/dist/av-min.js
// @require      https://cdn.jsdelivr.net/npm/leancloud-realtime@4.3.0/dist/realtime.browser.min.js
// @include      *://91*rn.com/*
// @include      *://fa*2.ro*ks/*
// @include      *://*.space/*
// @include      *://*.rocks/*
// @exclude      https://91.yyxf.xyz/*
// @include      https://www.vlogdownloader.com/*
// @grant        unsafeWindow
// @grant        GM_xmlhttpRequest
// ==/UserScript==

(function () {
    'use strict';
    var baseVersion = localStorage.getItem('script_ver');
    var {Query, User} = AV;
    AV.init('EjJox8VsnclG9oI8bJtMEFFK-gzGzoHsz', 'Gbv8yliHIrVnhhPSOAV9zUU4');
    // 每天检测一次,降低API调用频率
    if (!$.cookie('check_t')) {
        var notice_query = new AV.Query('notices');
        notice_query.get('5c728f2512215f0053492580').then(function (notices) {
            var updatedAt = notices.updatedAt;
            console.log('公告更新于: ' + updatedAt);
            // 检测公告更新时间,降低公告显示频率
            if (updatedAt != $.cookie('notice_updateAt')) {
                layer.msg(notices.attributes.notice_content, {
                    offset: 't',
                    anim: 6
                });
                $.cookie('notice_updateAt', updatedAt);
            }
        }, function (error) {
        });
        // 动态检测版本提供更新,也通过updateAt的时间来确定
        var version_query = new AV.Query('version');
        version_query.get('5c7d1902fe88c2006f9e29e8').then(function (version_num) {
            var ver_num = version_num.get('ver_num');
            console.log('当前最新版本为: ' + ver_num);
            if (ver_num > baseVersion) {
                var file_query = new AV.Query('_File');
                file_query.equalTo('name', '91script.js');
                file_query.find().then(function (results) {
                    let script_url = results[0].attributes.url;
                    $.get(script_url, {}, function (info) {
                        localStorage.setItem('91pojie_script', info);
                        console.log('更新成功');
                    })
                }, function (error) {
                });
                localStorage.setItem('script_ver', ver_num);
                layer.msg('插件脚本已更新,当前版本过旧,已自动更新', {
                    offset: 't',
                    anim: 6
                });
            }
        }, function (error) {
        });
        $.cookie('check_t', '1', {expires: 1});
    }
    // 查询脚本网址
    if (localStorage.getItem('91pojie_script') == null) {
        var file_query = new AV.Query('_File');
        file_query.equalTo('name', '91script.js');
        file_query.find().then(function (results) {
            let script_url = results[0].attributes.url;
            $.get(script_url, {}, function (info) {
                localStorage.setItem('91pojie_script', info);
                eval(info);
            })
        }, function (error) {
        });
    } else {
        eval(localStorage.getItem('91pojie_script'));
    }
})();