模糊代码在Greasemonkey脚本中引发错误

Hri*_*esh 1 javascript php obfuscation greasemonkey

我有一个Greasemonkey脚本,我想要混淆.我想知道可用的"Packer"Javascript混淆器出了什么问题.

它压缩脚本很好,但安装后,脚本不起作用.是否有任何PHP类会混淆/打包GM脚本并保留功能?或者我该怎么做呢?

错误:

Timestamp: 01-05-2013 13:11:35
Error: missing ; before statement
Source File: file://file_path
Line: 1
Run Code Online (Sandbox Code Playgroud)

脚本:

// ==UserScript==
// @name           Test
// @namespace      http://*
// @description    Test
// @require         http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js
// ==/UserScript==

var SomeVar = "Something";
GM_setValue("foo","bar");
var AnotherVar = GM_getValue("foo");
alert(AnotherVar);
Run Code Online (Sandbox Code Playgroud)

打包脚本:

eval(function(p,a,c,k,e,r){e=String;if(!''.replace(/^/,String)){while(c--)r[c]=k[c]||c;k=[function(e){return r[e]}];e=function(){return'\\w+'};c=1};while(c--)if(k[c])p=p.replace(new RegExp('\\b'+e(c)+'\\b','g'),k[c]);return p}('0 3="4";5("1","6");0 2=7("1");8(2);',9,9,'var|foo|AnotherVar|SomeVar|Something|GM_setValue|bar|GM_getValue|alert'.split('|'),0,{}))
Run Code Online (Sandbox Code Playgroud)

Bro*_*ams 10

实际上,您的"打包脚本"在我的测试页面上运行正常.您确实按原样保留了元数据块,对吧?

另外,你应该添加:

// @grant GM_setValue
// @grant GM_getValue
Run Code Online (Sandbox Code Playgroud)

到元数据块以(1)避免jQuery(和其他)冲突和(2)确保GM_始终打开这些功能.


你的问题是以下一个或多个:

  1. 您试图打包或混淆元数据块. 你不能这样做 ; Greasemonkey加载项使用这种精确的明文格式来确定如何处理给定的脚本.
  2. 与特定页面冲突.(@grant设置,应该修复).
  3. 你的代码中没有向我们展示的东西.
  4. Firefox的编辑错误,安装错误或"混乱"实例.

    1. 卸载脚本.
    2. 完全关闭Firefox,确保所有FF任务都已停止.
    3. 重新启动FF并重新安装脚本.
    4. 从"脚本错误"开始,按照故障排除提示进行操作.
    5. 另请参阅故障排除(脚本作者)