Code obfuscation causes an error in Greasemonkey Script

I have a Greasemonkey script that I want to confuse. I was wondering what happens with the affordable "Packer" Javascript obfuscator .

It compresses the script fine, but after installation the script does not work. Is there any PHP class that will confuse / package GM scripts and maintain functionality? Or how can I do this?

Mistake:

Timestamp: 01-05-2013 13:11:35 Error: missing ; before statement Source File: file://file_path Line: 1 

Script:

 // ==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); 

Packed Script:

 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,{})) 
+2
source share
1 answer

Actually, your "Packed Script" works fine on my test page. You did save the metadata block as , right?

In addition, you must add:

 // @grant GM_setValue // @grant GM_getValue 

in the metadata block to (1) avoid jQuery (and other) conflicts and (2) ensure that these GM_ functions GM_ always enabled.


Your problem is this:

  • You tried to pack or obfuscate a metadata block. You cannot do it ; The Greasemonkey add-on uses this clear text format to determine how to handle this script.
  • Conflict with a specific page. ( @grant settings should fix this).
  • Something in your code that you don’t show us.
  • Editing error, installation error, or "confusing" instance of Firefox.

+9
source

All Articles