Tampermonkey 如何在两个不同的网站上使用它

问题描述 投票:0回答:1

我有这样的问题,例如如何从一个网址获取信息并在另一个网址中使用它

// ==UserScript==
// @name         test
// @description  try to take over the world!
// @author       You
// @version      0.1
// @grant    GM_setValue
// @grant    GM_getValue
// @grant    GM_openInTab
// @grant    GM_SuperValue
// @include       https://tynachofinder.ge/*
// @include       https://tynachofinder.ge/finder/*
// @require       http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js
// @require https://userscripts-mirror.org/scripts/source/107941.user.js
// ==/UserScript==

GM.setValue("discord", document.querySelector(".site-btn").innerText);

document.querySelector(".header-section.clearfix").innerHTML = (
    GM.getValue("discord")
);

类似这样如何让它工作

javascript crosstab tampermonkey
1个回答
0
投票

要使 Tampermonkey 脚本匹配多个网站,您可以使用 @match 指令来指定脚本应运行的网页。 @match 的值应该是与您希望脚本运行的页面相匹配的 URL 模式。以下是您需要设置的 URL 模式部分:

@match <protocol>://<domain><path>

例如,如果您希望脚本在 example.com 的所有页面上运行,您可以使用:

@match https://example.com/*

如果您希望脚本在 example.com 和 example.net 的所有页面上运行,您可以使用:

@match https://example.com/* https://example.net/*

如果您希望脚本在 example.com 及其子域的所有页面上运行,您可以使用:

@match https://*.example.com/*

如果您希望脚本在 example.com 及其子域的所有页面以及 example.net 的所有页面上运行,您可以使用:

@match https://*.example.com/* https://example.net/*

如果您还有其他问题,请告诉我。

© www.soinside.com 2019 - 2024. All rights reserved.