MediaWiki:TabFocus.js

From CoraTO Wiki - Official Wiki
Jump to navigation Jump to search

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.
(function(){
  function g(id){try{return document.getElementById(id);}catch(_){return null}}
  function q(sel,ctx){try{return (ctx||document).querySelector(sel)}catch(_){return null}}
  function on(el,ev,fn){if(el){el.addEventListener(ev,fn)}}

  on(g('quick-start-coral'),'click',function(){
    setTimeout(function(){
      var nested=q('#tab-monkeyT .nested-tab[data-tab="coral-lv12"]');
      if(nested){nested.click()}
      var target=q('#coral-lv12');
      if(target){target.scrollIntoView({behavior:'smooth'})}
    },60);
  });

  on(g('quick-advance-techichi'),'click',function(){
    setTimeout(function(){
      var nested=q('#tab-monkeyT .nested-tab[data-tab="techichi-lv200"]');
      if(nested){nested.click()}
      var target=q('#techichi-lv200');
      if(target){target.scrollIntoView({behavior:'smooth'})}
    },60);
  });
})();