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 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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, ''));
        }
      });
  }
})();