Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. // ==UserScript==
  2. // @name Hover on is2.4chan
  3. // @version 1
  4. // @grant none
  5. // @include https://boards.4chan.org/*
  6. // @include https://boards.4channel.org/*
  7. // @require https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js
  8. // ==/UserScript==
  9.  
  10.  
  11.  
  12. (function() {
  13.  
  14. ///changes is2.4chan to i.4cdn
  15. var replacements, regex, key, textnodes, node, s;
  16.  
  17. replacements = {
  18.  
  19. "https://is2.4chan.org/": "https://i.4cdn.org/",
  20. };
  21.  
  22. regex = {};
  23. for (key in replacements) {
  24. regex[key] = new RegExp(key, 'g');
  25. }
  26.  
  27. textnodes = document.evaluate( "//body//text()", document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  28.  
  29. for (var i = 0; i < textnodes.snapshotLength; i++) {
  30. node = textnodes.snapshotItem(i);
  31. s = node.data;
  32. for (key in replacements) {
  33. s = s.replace(regex[key], replacements[key]);
  34. }
  35. node.data = s;
  36. }
  37. ///removes arbitrary wordbreak from links
  38.  
  39.  
  40. var element = document.getElementsByTagName("wbr"), index;
  41.  
  42. for (index = element.length - 1; index >= 0; index--) {
  43. element[index].parentNode.removeChild(element[index]);
  44. }
  45. ///removes referrer
  46.  
  47. document.querySelectorAll('a').forEach((a) => {
  48. const params = new URLSearchParams(a.href.split('?')[1]);
  49. a.href = '//' + params.get('url');
  50. });
  51. });
  52. })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement