Random Wikia

Press a button to go to any random page of the wikia you're on

当前为 2018-07-04 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Random Wikia
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.02
  5. // @description Press a button to go to any random page of the wikia you're on
  6. // @author RexOmni
  7. // @match http://*.wikia.com/*
  8. // @match https://*.wikia.com/*
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. 'use strict';
  14.  
  15. // Key that changes the page
  16. var randKey = 'f';
  17.  
  18. // Key that changes the page
  19. var saveKey = 'h';
  20.  
  21. // DO not edit below unless you know what you are doing
  22. window.addEventListener("keydown", function (event) {
  23. if(event.key==randKey){
  24. var url = window.location.href;
  25. var res = url.substring(0, url.indexOf("wikia.com")+9) + "/wiki/Special:Random";
  26.  
  27. window.location.replace(res);
  28. }
  29. else if(event.key==saveKey){
  30. var url = window.location.href;
  31. var stateObj = { };
  32. history.pushState(stateObj, document.title, url);
  33. }
  34. });
  35. })();