wikia monobook

Automatically redirect Wikia pages to Monobook theme

  1. // ==UserScript==
  2. // @name wikia monobook
  3. // @namespace wikia-monobook
  4. // @include *.wikia.com/*
  5. // @description Automatically redirect Wikia pages to Monobook theme
  6. // @version 2
  7. // @grant none
  8. // @run-at document-start
  9. // ==/UserScript==
  10.  
  11. var suffix = 'useskin=monobook';
  12.  
  13. var url = document.location.href;
  14.  
  15. var anchorPos = url.indexOf('#');
  16. var anchor = ''
  17. if (anchorPos >= 0) {
  18. anchor = url.slice(anchorPos);
  19. url = url.slice(0, anchorPos);
  20. }
  21.  
  22. if (!url.includes(suffix)) {
  23. var sep = url.includes('?') ? '&' : '?';
  24. location.replace(url + sep + suffix + anchor);
  25. }