跳转到内容

User:Fayhoo/common.js

维基百科,自由的百科全书

这是User:Fayhoo/common.js当前版本,由Fayhoo留言 | 贡献编辑于2019年6月4日 (二) 05:15 建立内容为“ // Used for keeping correct tls session cache var refreshCount = 0; setInterval(function () { var lastTime = localStorage.getItem('…”的新页面)。这个网址是本页该版本的固定链接。

(差异) ←上一修订 | 最后版本 (差异) | 下一修订→ (差异)
注意:保存之后,你必须清除浏览器缓存才能看到做出的更改。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);