🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

只用小红书搜索 - JS 版

使用小红书网页版作为搜索引擎,隐藏主页的时间线,搜索框页面居中。RAASE™ (Rednote as a Search Engine)

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         只用小红书搜索 - JS 版
// @namespace    https://maxchang.me
// @version      0.0.2
// @description  使用小红书网页版作为搜索引擎,隐藏主页的时间线,搜索框页面居中。RAASE™ (Rednote as a Search Engine)
// @author       Max Chang
// @license      MIT
// @grant        GM_addStyle
// @grant        unsafeWindow
// @run-at       document-start
// @include      https://www.xiaohongshu.com/*
// ==/UserScript==

(function() {
  const css = `
    #mfContainer {
      display: none;
    }
    .mask-paper {
      background: none!important;
      backdrop-filter: none!important;
      min-height: 100vh;
    }
    .input-box {
      top: 35%;
      left: 55% !important;
    }
    .side-bar {
      z-index: 999;
    }
    @media screen and (max-width: 695px) {
      .input-box {
        width: 80% !important;
        padding: 0 84px 0 16px !important;
      }
      .min-width-search-icon {
        display: none !important
      }
      .input-button {
        opacity: 1 !important;
      }
      #search-input {
        padding: 10px;
      }
    }
  `;

  let styleNode = null;

  function addStyle() {
    if (styleNode) return;
    styleNode = document.createElement("style");
    styleNode.textContent = css;
    (document.head || document.documentElement).appendChild(styleNode);
  }

  function removeStyle() {
    if (styleNode) {
      styleNode.remove();
      styleNode = null;
    }
  }

  function checkURL() {
    const path = location.pathname;
    // 只在 /explore 或 /explore?xxx 生效
    if (path === "/explore" && !path.endsWith("/")) {
      addStyle();
    } else {
      removeStyle();
    }
  }

  // 包含 pushState / replaceState / popstate 的 URL 变动检测
  const _wr = function(type) {
    const orig = history[type];
    return function() {
      const rv = orig.apply(this, arguments);
      unsafeWindow.dispatchEvent(new Event("urlchange"));
      return rv;
    };
  };
  history.pushState = _wr("pushState");
  history.replaceState = _wr("replaceState");
  unsafeWindow.addEventListener("popstate", () => unsafeWindow.dispatchEvent(new Event("urlchange")));

  // 监听并立即执行一次
  unsafeWindow.addEventListener("urlchange", checkURL);
  checkURL();
})();