Advertisement
Vectorman007

Fix Wikipedia max width USERSCRIPT.user.js

Mar 11th, 2021
440
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        Wikipedia Vector full-width
  3. // @namespace   sfghjs4uzrtjhgndh
  4. // @description Expands Wikipedia's Vector skin's interface
  5. // @include     https://fr.wikipedia.org/*
  6. // @include     https://he.wikipedia.org/*
  7. // @include     https://eu.wikipedia.org/*
  8. // @include     https://fa.wikipedia.org/*
  9. // @include     https://fr.wiktionary.org/*
  10. // @include     https://pt.wikiversity.org/*
  11. // @include     https://office.wikimedia.org/*
  12. // @include     https://pt.wikipedia.org/*
  13. // @include     https://tr.wikipedia.org/*
  14. // @include     https://ko.wikipedia.org/*
  15. // @include     https://sr.wikipedia.org/*
  16. // @include     https://de.wikivoyage.org/*
  17. // @version     1.0
  18. // @grant       none
  19. // ==/UserScript==
  20. var querystring = location.search;
  21. if (querystring == '') // empty
  22. {
  23.   window.location.replace(window.location.href + '?useskinversion=1');
  24. }
  25. else
  26. {
  27.   var query = querystring.substr(1);
  28.   var skinset = false;
  29.   query.split('&').forEach(function (part) {
  30.     var item = part.split('=');
  31.     if (decodeURIComponent(item[0]) == 'useskinversion')
  32.     {
  33.       skinset = decodeURIComponent(item[1]);
  34.     }
  35.   });
  36.   if (!skinset)
  37.   {
  38.     window.location.replace(window.location.href + '&useskinversion=1');
  39.   }
  40. }
  41. if (skinset == '1' || true) // replace the urls
  42. {
  43.   var links = document.getElementsByTagName('A');
  44.   anum = links.length;
  45.   for (var i = 0; i < anum; i++)
  46.   {
  47.     var href = links[i].href;
  48.     if (href == '' || href == null)
  49.     continue;
  50.     var hash = href.split('#');
  51.     var question = hash[0].split('?');
  52.     var final = '';
  53.     if (question.length > 1)
  54.     {
  55.       var thestring = hash[0].substr(question[0].length + 1);
  56.       var thisskinset = false;
  57.       thestring.split('&').forEach(function (part) {
  58.         var item = part.split('=');
  59.         if (decodeURIComponent(item[0]) == 'useskinversion')
  60.         {
  61.           thisskinset = true; //decodeURIComponent(item[1]);
  62.         }
  63.       });
  64.       if (thisskinset)
  65.       {
  66.         continue;
  67.       }
  68.       else
  69.       final = hash[0] + '&useskinversion=1';
  70.     }
  71.     else
  72.     final = hash[0] + '?useskinversion=1';
  73.     if (hash.length > 1)
  74.     final += href.substr(hash[0].length);
  75.     links[i].href = final;
  76.   }
  77. }
  78.  
  79. // Copyright 2021 Vectorman007
  80. // Comments, thanks, bug reports @ https://www.mediawiki.org/wiki/User_talk:Vectorman007
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement