Remove highlight from Mobilism

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

目前為 2024-05-06 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name        Remove highlight from Mobilism
// @namespace   https://github.com/AbdurazaaqMohammed
// @author       Abdurazaaq Mohammed
// @version     1.0.2
// @description Removes unnecessary highlight from Mobilism pages triggered when clicking on a search result to prevent potential issues with external links.
// @match       https://forum.mobilism.org/viewtopic.php?f=*
// @match       https://forum.mobilism.me/viewtopic.php?f=*
// @match       https://forum.mobilism.org/search.php?*
// @match       https://forum.mobilism.me/search.php?*
// @grant       none
// @run-at      document-start
// @homepage    https://github.com/AbdurazaaqMohammed/userscripts
// @supportURL  https://github.com/AbdurazaaqMohammed/userscripts/issues
// @license      The Unlicense
// ==/UserScript==

(function() {
  'use strict';


  const url = window.location.href;
  if (url.includes('viewtopic')) {
    const index = url.indexOf("&hilit");
    if (index > -1) window.location.href = url.substring(0, index);
  } else {
      addEventListener("load", (event) => {
        const topics = document.querySelectorAll('.topictitle');
        const latestPosts = document.querySelectorAll('a[rel="tooltip"]');
        const toBeReplaced = '&hilit=' + document.querySelector('h3 > [href^="./search.php"]').innerText.replaceAll(' ', '+');

        for (let i = 0; i < topics.length; i++) {
          const topic = topics[i];
          const latestPost = latestPosts[i];
          const topicLink = $(topic).attr('href').toString();
          const latestPostLink = $(latestPost).attr('href').toString();

          topic.setAttribute('href', topicLink.replace(toBeReplaced, ''));
          latestPost.setAttribute('href', latestPostLink.replace(toBeReplaced, ''));
        }
      });
  }
})();