Advertisement
Guest User

Untitled

a guest
Dec 10th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. // ==UserScript==
  2. // @grant none
  3. // @match https://*.wikipedia.org/*
  4. // @name Wikipedia
  5. // ==/UserScript==
  6.  
  7. (function() {
  8. 'use strict';
  9.  
  10. function actionFunction() {
  11. var links = document.querySelectorAll('a');
  12. var i;
  13. for (i = 0; i < links.length; i++) {
  14. var input = document.createElement('input');
  15. input.type = 'checkbox';
  16. input.dataset.url = links[i].href;
  17. input.addEventListener('change', function() {
  18. let desired_url = this.dataset.url;
  19. let current_url = window.location.href;
  20. history.replaceState({}, '', desired_url);
  21. history.replaceState({}, '', current_url);
  22. });
  23. links[i].parentElement.insertBefore(input, links[i].nextSibling);
  24. }
  25. }
  26.  
  27. actionFunction();
  28. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement