Remove highlight from Mobilism

Removes unnecessary highlight from Mobilism pages triggered when clicking on a search result to prevent potential issues with external links.

  1. // ==UserScript==
  2. // @name Remove highlight from Mobilism
  3. // @namespace https://github.com/AbdurazaaqMohammed
  4. // @author Abdurazaaq Mohammed
  5. // @version 1.0.2
  6. // @description Removes unnecessary highlight from Mobilism pages triggered when clicking on a search result to prevent potential issues with external links.
  7. // @match https://forum.mobilism.org/viewtopic.php?f=*
  8. // @match https://forum.mobilism.me/viewtopic.php?f=*
  9. // @match https://forum.mobilism.org/search.php?*
  10. // @match https://forum.mobilism.me/search.php?*
  11. // @grant none
  12. // @run-at document-start
  13. // @homepage https://github.com/AbdurazaaqMohammed/userscripts
  14. // @supportURL https://github.com/AbdurazaaqMohammed/userscripts/issues
  15. // @license The Unlicense
  16. // ==/UserScript==
  17.  
  18. (function() {
  19. 'use strict';
  20.  
  21.  
  22. const url = window.location.href;
  23. if (url.includes('viewtopic')) {
  24. const index = url.indexOf("&hilit");
  25. if (index > -1) window.location.href = url.substring(0, index);
  26. } else {
  27. addEventListener("load", (event) => {
  28. const topics = document.querySelectorAll('.topictitle');
  29. const latestPosts = document.querySelectorAll('a[rel="tooltip"]');
  30. const toBeReplaced = '&hilit=' + document.querySelector('h3 > [href^="./search.php"]').innerText.replaceAll(' ', '+');
  31.  
  32. for (let i = 0; i < topics.length; i++) {
  33. const topic = topics[i];
  34. const latestPost = latestPosts[i];
  35. const topicLink = $(topic).attr('href').toString();
  36. const latestPostLink = $(latestPost).attr('href').toString();
  37.  
  38. topic.setAttribute('href', topicLink.replace(toBeReplaced, ''));
  39. latestPost.setAttribute('href', latestPostLink.replace(toBeReplaced, ''));
  40. }
  41. });
  42. }
  43. })();