MediaWiki討論:Gadget-AdvancedSiteNotices.js
新增話題Gadget throwing JS errors on the mobile site
[編輯]This gadget is throwing errors on mobile site e.g. https://zh.m.wikipedia.org/wiki/%E7%AC%AC%E4%BA%8C%E6%AC%A1%E4%B8%96%E7%95%8C%E5%A4%A7%E6%88%98:
Uncaught SyntaxError: Unexpected token ) at testCriteria (<anonymous>:235:177) at matchCriteria (<anonymous>:235:195) at loadNotices (<anonymous>:235:451) at Object.success (<anonymous>:236:699) at fire (load.php?lang=zh-hk&modules=jquery&skin=minerva&version=0hmxo20:45) at Object.fireWith [as resolveWith] (load.php?lang=zh-hk&modules=jquery&skin=minerva&version=0hmxo20:47) at done (load.php?lang=zh-hk&modules=jquery&skin=minerva&version=0hmxo20:126) at XMLHttpRequest.<anonymous> (load.php?lang=zh-hk&modules=jquery&skin=minerva&version=0hmxo20:130)
Jdlrobson(留言) 2019年8月7日 (三) 17:26 (UTC)
- Fixed in Special:Diff/55559839. --Xiplus#Talk 2019年8月8日 (四) 00:14 (UTC)
在上方的消息「跑馬燈」
[編輯]以前在上面的消息「跑馬燈」只要按 [關閉] 之後,在維基百科的頁面之間就不會再出現了(直到下次),但現在按下 [關閉] 卻只有單次有效,轉到其他頁面仍然出現?是強迫收看嗎?--Tp0910(留言) 2020年10月3日 (六) 20:46 (UTC)
- @Xiplus:最後一個版本被改壞了。
rev === cval
應該是不能用===
的,因為$.cookie(cname)
獲取不到內容的時候返回的是null
。同時我也不太明白為什麼上面的if (cval == '') { cval = -1 }
會這樣寫,null == ''
這始終是false
的。 --安憶Talk 2020年10月4日 (日) 04:05 (UTC)- 已回退。--Xiplus#Talk 2020年10月4日 (日) 04:19 (UTC)
- 感謝各位。--Tp0910(留言) 2020年10月4日 (日) 14:42 (UTC)
- 已回退。--Xiplus#Talk 2020年10月4日 (日) 04:19 (UTC)
too much recursion
[編輯]This error is thrown on https://zh.wikipedia.org/wiki/%E5%A4%A7%E9%B1%BC%E6%B5%B7%E6%A3%A0 Anoymized stack trace:
at html/< URL1:222:664 at access URL1:193:243 at html URL1:222:504 at loadNotices/< URL2:4:168 at jQuery.speed/opt.complete URL1:242:22 at fire URL1:186:191 at fireWith URL1:187:402 at tick URL1:239:241 at jQuery.fx.tick URL1:244:750 at schedule URL1:234:991
Jon (WMF)(留言) 2020年10月20日 (二) 21:09 (UTC)
編輯請求 2021-08-18
[編輯] 請求已處理。--安憶Talk 2021年8月18日 (三) 02:59 (UTC)
把第71行的jQuery.trim
改成String.prototype.trim
,控制台一堆deprecate警告-- Sunny00217 2021年8月18日 (三) 02:52 (UTC)
The gadget is not in real time when using with numbers
[編輯]Hello, in ckb:Template:AdvancedSiteNotices, we used if expression with two deletion categories (for admins only). It is obvious that category members increase and decrease. The problem here is that the AdvancedSiteNotices does not update at all and is not real time. I just investigated the problem a little bit and went to the ckb:Template:AdvancedSiteNotices/ajax. I cleaned it's cache up and it updated in the AdvancedSiteNotices, but I wasn't sure if it was updated only for me or for other administrators and it will updated for all admins. Can you fix this problem?--Aram(留言) 2023年1月10日 (二) 19:29 (UTC)
編輯請求 2025-01-26
[編輯] 請求已處理
- 優化外觀及移動版佈局,關閉操作使用真按鈕;
- 去屎山代碼。
部署方法:
- 小工具定義加上
AdvancedSiteNotices.css
; - https://zh.wikipedia.beta.wmflabs.org/wiki/MediaWiki:Gadget-AdvancedSiteNotices.css => MediaWiki:Gadget-AdvancedSiteNotices.css;
- https://zh.wikipedia.beta.wmflabs.org/wiki/MediaWiki:Gadget-AdvancedSiteNotices.js => MediaWiki:Gadget-AdvancedSiteNotices.js。
以上。--碟之舞📀💿 2025年1月26日 (日) 08:59 (UTC)
編輯請求 2025-03-21
[編輯] 請求已處理。--安憶Talk 2025年3月24日 (一) 06:32 (UTC)
初步解決phab:T384827,修改內容:
- https://zh.wikipedia.beta.wmflabs.org/wiki/MediaWiki:Gadget-AdvancedSiteNotices.js => MediaWiki:Gadget-AdvancedSiteNotices.js
- https://zh.wikipedia.beta.wmflabs.org/wiki/MediaWiki:Gadget-AdvancedSiteNotices.css => MediaWiki:Gadget-AdvancedSiteNotices.css
附知@SunAfterRain。--碟之舞📀💿 2025年3月21日 (五) 14:10 (UTC)
- 這個工單大體是什麼內容?我這邊無權查看。--安憶Talk 2025年3月22日 (六) 08:11 (UTC)
- I reviewed the email. I believe that if we operate on zhwiki with a clear usage method, established expressions, controllable pages, and trusted administrators, using
eval()
for execution does not present a security risk. Whileeval()
can raise security concerns in uncontrolled environments where arbitrary expressions may be executed, this is not the case under the conditions mentioned. Like "Setting aside the facts, is there really no problem with XXX?", is unreasonable and disregards these facts.--安憶Talk 2025年3月24日 (一) 05:52 (UTC)- @AnYiLin:見Telegram私信。--碟之舞📀💿 2025年3月24日 (一) 06:07 (UTC)
- Given the assumption that "administrators are not entirely trustworthy," I agree to adopt a more controllable parsing method.--安憶Talk 2025年3月24日 (一) 06:36 (UTC)
- @AnYiLin:見Telegram私信。--碟之舞📀💿 2025年3月24日 (一) 06:07 (UTC)
- I reviewed the email. I believe that if we operate on zhwiki with a clear usage method, established expressions, controllable pages, and trusted administrators, using
編輯請求 2025-04-12
[編輯] 請求已處理。--安憶Talk 2025年4月12日 (六) 07:12 (UTC)
新JS位於[1],CSS無變更。
變化:
- 確保先處理
&&
再處理||
。 - 加入文檔中缺失的測試方法(主要為了兼容臨時賬號)。
- 修正Cookie有效時間為正確的30天而非1800天。
- 頂部加入警告消息要求其他wiki的導入者保護相關頁面。
以上。--碟之舞📀💿 2025年4月12日 (六) 07:00 (UTC)
- @Diskdance:其實我覺得Cookie時間那裏直接用本地存儲也可以。除非有新公告,用戶選擇不顯示就一直保持不顯示,不然關都關了某段時間之後又自己顯示了感覺上有些奇怪。--安憶Talk 2025年4月12日 (六) 07:19 (UTC)
- 我也覺得是,但是考慮到先前的代碼已經生成很多遺留Cookie了,所以當時就沒改。--碟之舞📀💿 2025年4月12日 (六) 07:21 (UTC)
- @Diskdance、AnYiLin:
Parse error: Unexpected: ) on line 556 in MediaWiki:Gadget-AdvancedSiteNotices.js
,在beta站和這裏都出錯。那個位置看似沒有syntax錯誤但都還是fry了。--路西法人 2025年4月15日 (二) 06:03 (UTC)囧rz……--RainBeforeSun(留言) 2025年4月15日 (二) 10:43 (UTC)
- 是的,很抱歉一時大意沒有在Beta站檢查出這個問題
囧rz……--碟之舞📀💿 2025年4月15日 (二) 10:47 (UTC)
- e04,對耶,那個是函數內的尾隨逗號
囧rz……印象中尾隨逗號本來就是一回事,但我自己沒在函數內用過尾隨逗號,難怪我不知道這回事(--路西法人 2025年4月15日 (二) 11:03 (UTC)
- 看到了郵件,改掉了。我的建議是推廣Prettier的使用,我本地看了下它會把那個逗號格式化掉。--安憶Talk 2025年4月15日 (二) 17:06 (UTC)
- 看到了個ESLint的規則,能指定可用的最高ES版本的語法,https://eslint-community.github.io/eslint-plugin-es-x/--安憶Talk 2025年4月15日 (二) 17:29 (UTC)
- 看到了郵件,改掉了。我的建議是推廣Prettier的使用,我本地看了下它會把那個逗號格式化掉。--安憶Talk 2025年4月15日 (二) 17:06 (UTC)
因為555行的函數參數尾隨逗號要ES2017才支援- 是的,很抱歉一時大意沒有在Beta站檢查出這個問題