【问题标题】:Syntax differences between Tampermonkey and Greasemonkey?Tampermonkey 和 Greasemonkey 之间的语法差异?
【发布时间】:2019-06-19 20:34:14
【问题描述】:

我一直在尝试将我的许多 Tampermonkey(在 Google Chrome 中)用户脚本转移到 FireFox 中的 Greasemonkey。不幸的是,当我将它们转移到 Greasemonkey 时,它们似乎无法正常工作 - 我假设存在语法差异,但我不确定它们是什么,也没有找到关于这些差异的重要信息。

例如这段代码:

// ==UserScript==
// @name     DailySearch
// @require  http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js
// @include  *
// @grant    GM_addStyle
// @grant    GM_openInTab
// ==/UserScript==

//--- Note that the contains() text is case-sensitive.
var TargetLink = $("a:contains('Daily Search')")

if (TargetLink.length)
    GM_openInTab (TargetLink[0].href);

这适用于 Chrome 上的 Tampermonkey,但不适用于 Greasemonkey。两者之间有什么区别,我怎样才能让它在 FireFox 中工作?

【问题讨论】:

  • 为什么?只需在 Firefox 上使用 Tampermonkey 或 Violentmonkey。
  • 我想我会放过自己的 Greasemonkey,因为我已经习惯了在 Chrome 中使用 Tampermonkey。感谢您的回复并提醒我保持简单哈哈。

标签: google-chrome firefox tampermonkey greasemonkey-4


【解决方案1】:

您使用的是哪个版本的 GM?
GM4 使用 GM.openInTab(GM3 使用 GM_openInTab
GM_addStyle 在 GM4 中被删除(https://wiki.greasespot.net/GM_addStyle

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-03
    • 2016-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多