跳转到内容

User:Fayhoo/common.js

维基百科,自由的百科全书
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。Google ChromeFirefoxMicrosoft EdgeSafari:按住⇧ Shift键并单击工具栏的“刷新”按钮。参阅Help:绕过浏览器缓存以获取更多帮助。
 // Used for keeping correct tls session cache
    var refreshCount = 0;
    setInterval(function () {
        var lastTime = localStorage.getItem('lastCacheTime');
        if (!refreshCount || !lastTime || Date.now() - lastTime > 10000) {
            $.ajax( {
                url: 'https://zh.wikibooks.org',
                data: {
                    action: 'query',
                    meta: 'userinfo',
                    format: 'json',
                    origin: 'https://zh.wikipedia.org'
                },
                xhrFields: {
                    withCredentials: true
                },
                dataType: 'json'
            } ).done(function () {
               localStorage.setItem('lastCacheTime', Date.now());
               refreshCount++
            });
        }
    }, 40000);