slashdot de-hostify links

remove hostnames from slashdot domains

  1. // ==UserScript==
  2. // @name slashdot de-hostify links
  3. // @namespace slashdot
  4. // @description remove hostnames from slashdot domains
  5. // @include https://slashdot.org/*
  6. // @version 0.1a
  7. // @grant none
  8. // ==/UserScript==
  9. var pattern = /^https:\/\/.*\.slashdot\.org\//
  10. var pattern2 = /^\/\/.*\.slashdot\.org\//
  11. anchor = document.getElementsByTagName('a');
  12. for (i = 0; i < anchor.length; i++) {
  13. if (pattern.test(anchor[i].href)) {
  14. anchor[i].href = anchor[i].href.replace(pattern, 'https://slashdot.org/');
  15. }
  16. if (pattern2.test(anchor[i].href)) {
  17. anchor[i].href = anchor[i].href.replace(pattern2, '//slashdot.org/');
  18. }
  19. }