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

Greasy fork 爱吃馍镜像

Greasy Fork is available in English.

📂 缓存分发状态(共享加速已生效)
🕒 页面同步时间:2026/01/18 18:31:53
🔄 下次更新时间:2026/01/18 19:31:53
手动刷新缓存

topPost

置顶v2ex高赞回复

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

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

(I already have a user script manager, let me install it!)

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

公众号二维码

扫码关注【爱吃馍】

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

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.

(I already have a user style manager, let me install it!)

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

公众号二维码

扫码关注【爱吃馍】

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

// ==UserScript==
// @name         topPost
// @namespace    http://tampermonkey.net/
// @version      0.2
// @description  置顶v2ex高赞回复
// @author       yuyinws
// @match        *://v2ex.com/t/*
// @match        *://*.v2ex.com/t/*
// @grant        GM_registerMenuCommand
// @grant        GM_unregisterMenuCommand
// @grant        GM_getValue
// @grant        GM_setValue
// @icon         https://www.v2ex.com/static/favicon.ico
// @run-at       document-end
// @license      MIT
// ==/UserScript==
(() => {
  // star限制值
  let starLimit = GM_getValue("starLimit") || 5;
  // 菜单注册
  GM_registerMenuCommand(`star限制值:${starLimit}(点击修改)`, () => {
    let starLimit = prompt("请输入");
    GM_setValue("starLimit", starLimit);
  });

  let postMap = new Map();

  let topEl = document.createElement("div");
  topEl.className = "box";

  let refEl = document.querySelector("#Main").childNodes[5];

  let sepEl = document.createElement("div");
  sepEl.className = "sep20";

  let cellEl = document.createElement("div");
  cellEl.className = "cell";
  cellEl.innerText = "高赞回复";

  // 获取所有有star的回复
  document.querySelectorAll("div[id^=r_]").forEach((item) => {
    let clonedItem = item.cloneNode(true);
    if (clonedItem.querySelector(".fade")) {
      let star = Number(clonedItem.querySelector(".fade").innerText);
      if (star >= starLimit) {
        postMap.set(clonedItem, Number(item.querySelector(".fade").innerText));
      }
    }
  });

  // 排序
  const sortMap = new Map([...postMap].sort((a, b) => b[1] - a[1]));
  if (sortMap.size > 0) {
    topEl.appendChild(cellEl);
    for (let [key] of sortMap) {
      topEl.appendChild(key);
    }
    refEl.parentNode.insertBefore(sepEl, refEl);
    refEl.parentNode.insertBefore(topEl, refEl);
  }
})();