Random Wikia

Press 'f'to goto any random page of the wikia your're on

当前为 2016-12-06 提交的版本,查看 最新版本

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