Tampermonkey忽略了@exclude

ale*_*aiz 7 javascript google-chrome shopify tampermonkey

我正在使用Tampermonkey 翻译Shopify的仪表板/管理员.

出于安全考虑,Shopify管理员仪表板的某些部分我不想使用Tampermonkey.商家创建的文本(产品,页面,集合,模板......)是Tampermonkey取代的,这是非常危险的.

有两种方法可以解决这个问题:

  1. "Instruct"Tampermonkey不翻译表单内的内容.(这似乎是最好的方法)
  2. 使用该@exclude指令.

我使用了后者,但脚本没有收听@exclude.这是用户脚本:

// ==UserScript==
// @name       Shopify_Admin_Spanish
// @namespace  http://*.myshopify.com/admin
// @version    0.1
// @description  Tu tienda Shopify, por detrás, en español!
// @exclude    https://*.myshopify.com/admin/products
// @exclude    https://*.myshopify.com/admin/collections
// @exclude    https://*.myshopify.com/admin/blogs
// @exclude    https://*.myshopify.com/admin/pages
// @exclude    https://*.myshopify.com/admin/themes
// @match      https://*.myshopify.com/*
// @copyright  microapps.com
// ==/UserScript==
Run Code Online (Sandbox Code Playgroud)

PS.我使用谷歌浏览器进行了所有检查,并且不愿意使用任何其他浏览器.

Bro*_*ams 9

@exclude非常精确 您需要在每个排除行上放置尾随星号。例如:

// @exclude    https://*.myshopify.com/admin/products*
// @exclude    https://*.myshopify.com/admin/collections*
// @exclude    https://*.myshopify.com/admin/blogs*
// @exclude    https://*.myshopify.com/admin/pages*
// @exclude    https://*.myshopify.com/admin/themes*
Run Code Online (Sandbox Code Playgroud)

考虑(并安装)此Tampermonkey脚本:

// ==UserScript==
// @name     _match and exclude testing
// @match    http://*.stackexchange.com/*
//
// @exclude  http://*.stackexchange.com/questions*
// @exclude  http://*.stackexchange.com/tags
// @require  http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js
// @grant    GM_addStyle
// ==/UserScript==

$("body").prepend ('<h1 style="background: yellow;">Match Script fired on this page.</h1>');
Run Code Online (Sandbox Code Playgroud)

如果您随后访问arduino.stackexchange.com/tags,则脚本不会触发,但是在访问时:

它会!

将第二个排除行更改为:

// @exclude  http://*.stackexchange.com/tags*
Run Code Online (Sandbox Code Playgroud)

解决问题。


如果仍然有困难,请指定您的Chrome,Tampermonkey和操作系统的版本。并且,提供演示该问题的目标页面。