Jump to content
Wikimedia Meta-Wiki

User:SunAfterRain/js/zh-varient.js

From Meta, a Wikimedia project coordination wiki

Note: After publishing, you may have to bypass your browser's cache to see the changes.

  • Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
  • Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
  • Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5.
 /**
  * View page in zh-* variant
  * Enable on page with "content language" set to 'zh-*'
  * i.e. translatable page's subpage,
  * manually switched page on multilingual sites etc.
  * Exempt on Chinese Wikimedia projects
  * 
  * set window.wgUseZhVarientAutoRedirectToVarient to your perfect chinese variant to enable script
  * 
  * from https://meta.wikimedia.org/w/index.php?title=User:Stang/js/use_zh-cn.js&oldid=23157310
  * @Author WhitePhosphorus
  */
 (function(){
 if(!window.wgUseZhVarientAutoRedirectToVarient){
 return;
 }
 varconfig=mw.config.get(['wgContentLanguage','wgPageContentLanguage','wgAction','wgDiffNewId']);
 if(
 config.wgContentLanguage!=='zh'&&
 /zh(-(hans|hant|cn|hk|mo|tw|ms|sg))?$/.test(config.wgPageContentLanguage)&&
 config.wgAction==='view'&&
 !config.wgDiffNewId&&
 $('.ca-variants-zh').length!==0
 ){
 varurl=newURL(document.URL);
 if(!url.searchParams.has('variant')){
 url.searchParams.set('variant',window.wgUseZhVarientAutoRedirectToVarient);
 window.location.replace(url.href);
 }
 }

 }());

AltStyle によって変換されたページ (->オリジナル) /