From 7b57ec51341235a09da8d2f2b110b5c1f10c0451 Mon Sep 17 00:00:00 2001 From: Lex Lim Date: Wed, 4 Jan 2023 22:15:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DJS=E7=9A=84=E5=85=BC=E5=AE=B9?= =?UTF-8?q?=E6=80=A7=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- modules/ext.isekai.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/modules/ext.isekai.js b/modules/ext.isekai.js index 887a687..def43ff 100644 --- a/modules/ext.isekai.js +++ b/modules/ext.isekai.js @@ -1,23 +1,41 @@ var offsetSize = (function() { - if (mw.config.get('skin') === 'timeless') { + if (mw.config.get('skin') === 'timeless' && window.innerWidth > 850) { return 55; + } else if (mw.config.get('skin') === 'minerva') { + return 56; } else { return 0; } })(); var scrollBehaviorAvaliable = (function() { + // 检测Chrome var v = navigator.userAgent.match(/Chrome\/(?\S+)/); - if (v && v.groups.version) { // 检测chrome版本 + if (v && v.groups.version) { var chromeVersion = parseInt(v.groups.version); return chromeVersion >= 61; - } else { // 非chrome - return true; } + + // 检测Firefox + v = navigator.userAgent.match(/Firefox\/(?\S+)/); + if (v && v.groups.version) { + var firefoxVersion = parseInt(v.groups.version); + return firefoxVersion >= 36; + } + + // 检测Safari + v = navigator.userAgent.match(/Version\/(?\S+)/); + if (v && v.groups.version) { // Safari + var safariVersion = parseFloat(v.groups.version); + return safariVersion >= 14; + } + + return false; })(); function scrollToAnchor(link){ - var target = $(link.replace(/\./g, '\\.')); - if(target.length > 0){ + var el = document.getElementById(link.replace(/^#/, '')); + if (el) { + var target = $(el); target.click(function(){ return false; }); var position = target.offset().top - offsetSize; if (scrollBehaviorAvaliable) {