Wrong format?

Discussions and Tech Support related to the iMacros Firefox Add-on, including the built-in Javascript scripting interface for playing .js files.
Forum rules
Before asking a question or reporting an issue:
1. Please review the list of FAQ's.
2. Use the search box (at the top of each forum page) to see if a similar problem or question has already been addressed.
3. Try searching the iMacros Wiki - it contains the complete iMacros reference as well as plenty of samples and tutorials.
4. We can respond much faster to your posts if you include the following information: CLICK HERE FOR IMPORTANT INFORMATION TO INCLUDE IN YOUR POST
Post Reply
Pucca
Posts: 8
Joined: Fri Jan 15, 2016 10:31 am

Wrong format?

Post by Pucca » Wed Jun 06, 2018 4:27 am

I'm having trouble fixing my code on javascript cause when I try to play it gives the error: wrong format of SET command, line 16 (Error code: -910)
So line 16 is

Code: Select all

check += "SET !EXTRACT NULL" + "\n"; 
but I don't see any incorrect syntax. Can anyone help me fix my code?

Code: Select all

var check; 
check = "CODE:"; 
check += "SET api_key \"1abc234de56fab7c89012d34e56fa7b8\"" + "\n";  
check += "SET !EXTRACT_TEST_POPUP NO" + "\n";  
check += "SET !ERRORIGNORE YES" + "\n";  
check += "SET !TIMEOUT_PAGE 1" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "URL GOTO = javascript:(function(){g=document.getElementsByClassName('g-recaptcha-response');%20g.setAttribute('myatt1',window.location.href);%20g.setAttribute('myatt2',document.getElementById('recaptcha-demo').attributes['data-sitekey'].value);})();" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=ID:g-recaptcha-response EXTRACT=HTM" + "\n";  
check += "SET pgurl EVAL(\"'{{!EXTRACT}}'.match(/myatt1=[\"'](.+?)[\"']/)[1];\")" + "\n";  
check += "SET gkey EVAL(\"'{{!EXTRACT}}'.match(/myatt2=[\"'](.+?)[\"']/)[1];\")" + "\n";  
check += "URL GOTO=javascript:((function(){var%20a=window.content.document.getElementsByTagName('iframe');%20%20var%20k='';%20%20for(var%20x=0;x<a.length;x++)%20%20{%20%20%20if(a[x].src.includes('https://www.google.com/recaptcha/api2/anchor?k'))%20%20%20{%20%20%20%20k=a[x].src.split('?k=')[1].split('&')[0];%20%20%20%20a[x].setAttribute(\"name\",\"I0_myownid\");%20%20%20%20window.content.document.getElementsByClassName('g-recaptcha-response').style.display='';%20%20%20%20break;%20%20%20}%20%20}%20%20window.content.document.getElementsByClassName('g-recaptcha-response').textContent='';}))();" + "\n";  
check += "SET !TIMEOUT_PAGE 60" + "\n";  
check += "TAG POS=1 TYPE=TEXTAREA FORM=ID:* ATTR=CLASS:g-recaptcha-response EXTRACT=TXT" + "\n";  
check += "SET k {{!EXTRACT}}" + "\n";   
check += "SET !EXTRACT NULL" + "\n"; 
check += "TAG POS=2 TYPE=IFRAME ATTR=* EXTRACT=HTM" + "\n";  
check += "SET !VAR1 EVAL(\"var s=\"{{!EXTRACT}}\"; var string=s.match(/k=([^&]*)/i)[1];string;\")" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
check += "TAB OPEN" + "\n";  
check += "TAB T=2" + "\n";  
check += "URL GOTO=http://127.0.0.3/in.php?key={{api_key}}&method=userrecaptcha&googlekey={{!VAR1}}&pageurl=http://omegle.com" + "\n";  
check += "WAIT SECONDS=1" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT" + "\n";  
check += "SET captid EVAL(\"var s=\"{{!EXTRACT}}\"; s.split(' ')[0].split('|')[1]\")" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
check += "URL GOTO= http://127.0.0.3/res.php?key={{api_key}}&action=get&id={{captid}}" + "\n";  
check += "WAIT SECONDS=120" + "\n";  
check += "REFRESH" + "\n";  
check += "WAIT SECONDS=1" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT" + "\n";  
check += "SET answer EVAL(\"var s=\"{{!EXTRACT}}\"; s.split(' ')[0].split('|')[1]\")" + "\n";  
check += "SET !EXTRACT {{answer}}" + "\n";  
check += "TAB CLOSE" + "\n";  
check += "TAB T=1" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "TAG POS=1 TYPE=TEXTAREA FORM=ID:g-recaptcha-response* ATTR=CLASS:g-recaptcha-response CONTENT={{answer}}" + "\n";  
check += "URL GOTO=javascript:(function(){___grecaptcha_cfg.clients[0].ba.l.callback(\"{{answer}}\");})();" + "\n";    
check += "URL GOTO=javascript:(function(){recaptchaSolved(\"{{answer}}\");})();" + "\n";  
check += "URL GOTO=javascript:(function(){document.getElementsByClassName(\"g-recaptcha-response\").innerHTML=\"{{answer}}\";onSuccess();})();" + "\n";  
check += "URL GOTO = javascript:onSuccess();" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "SET answer NULL" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
iimPlay(check);
Firefox 55.0.2
Imacros Firefox 9.0.3
Windows 10 Home
chivracq
Posts: 8929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Wrong format?

Post by chivracq » Wed Jun 06, 2018 5:03 am

Pucca wrote:I'm having trouble fixing my code on javascript cause when I try to play it gives the error: wrong format of SET command, line 16 (Error code: -910)
So line 16 is

Code: Select all

check += "SET !EXTRACT NULL" + "\n"; 
but I don't see any incorrect syntax. Can anyone help me fix my code?

Code: Select all

var check; 
check = "CODE:"; 
check += "SET api_key \"1abc234de56fab7c89012d34e56fa7b8\"" + "\n";  
check += "SET !EXTRACT_TEST_POPUP NO" + "\n";  
check += "SET !ERRORIGNORE YES" + "\n";  
check += "SET !TIMEOUT_PAGE 1" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "URL GOTO = javascript:(function(){g=document.getElementsByClassName('g-recaptcha-response');%20g.setAttribute('myatt1',window.location.href);%20g.setAttribute('myatt2',document.getElementById('recaptcha-demo').attributes['data-sitekey'].value);})();" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=ID:g-recaptcha-response EXTRACT=HTM" + "\n";  
check += "SET pgurl EVAL(\"'{{!EXTRACT}}'.match(/myatt1=[\"'](.+?)[\"']/)[1];\")" + "\n";  
check += "SET gkey EVAL(\"'{{!EXTRACT}}'.match(/myatt2=[\"'](.+?)[\"']/)[1];\")" + "\n";  
check += "URL GOTO=javascript:((function(){var%20a=window.content.document.getElementsByTagName('iframe');%20%20var%20k='';%20%20for(var%20x=0;x<a.length;x++)%20%20{%20%20%20if(a[x].src.includes('https://www.google.com/recaptcha/api2/anchor?k'))%20%20%20{%20%20%20%20k=a[x].src.split('?k=')[1].split('&')[0];%20%20%20%20a[x].setAttribute(\"name\",\"I0_myownid\");%20%20%20%20window.content.document.getElementsByClassName('g-recaptcha-response').style.display='';%20%20%20%20break;%20%20%20}%20%20}%20%20window.content.document.getElementsByClassName('g-recaptcha-response').textContent='';}))();" + "\n";  
check += "SET !TIMEOUT_PAGE 60" + "\n";  
check += "TAG POS=1 TYPE=TEXTAREA FORM=ID:* ATTR=CLASS:g-recaptcha-response EXTRACT=TXT" + "\n";  
check += "SET k {{!EXTRACT}}" + "\n";   
check += "SET !EXTRACT NULL" + "\n"; 
check += "TAG POS=2 TYPE=IFRAME ATTR=* EXTRACT=HTM" + "\n";  
check += "SET !VAR1 EVAL(\"var s=\"{{!EXTRACT}}\"; var string=s.match(/k=([^&]*)/i)[1];string;\")" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
check += "TAB OPEN" + "\n";  
check += "TAB T=2" + "\n";  
check += "URL GOTO=http://127.0.0.3/in.php?key={{api_key}}&method=userrecaptcha&googlekey={{!VAR1}}&pageurl=http://omegle.com" + "\n";  
check += "WAIT SECONDS=1" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT" + "\n";  
check += "SET captid EVAL(\"var s=\"{{!EXTRACT}}\"; s.split(' ')[0].split('|')[1]\")" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
check += "URL GOTO= http://127.0.0.3/res.php?key={{api_key}}&action=get&id={{captid}}" + "\n";  
check += "WAIT SECONDS=120" + "\n";  
check += "REFRESH" + "\n";  
check += "WAIT SECONDS=1" + "\n";  
check += "TAG POS=1 TYPE=* ATTR=TXT:* EXTRACT=TXT" + "\n";  
check += "SET answer EVAL(\"var s=\"{{!EXTRACT}}\"; s.split(' ')[0].split('|')[1]\")" + "\n";  
check += "SET !EXTRACT {{answer}}" + "\n";  
check += "TAB CLOSE" + "\n";  
check += "TAB T=1" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "TAG POS=1 TYPE=TEXTAREA FORM=ID:g-recaptcha-response* ATTR=CLASS:g-recaptcha-response CONTENT={{answer}}" + "\n";  
check += "URL GOTO=javascript:(function(){___grecaptcha_cfg.clients[0].ba.l.callback(\"{{answer}}\");})();" + "\n";    
check += "URL GOTO=javascript:(function(){recaptchaSolved(\"{{answer}}\");})();" + "\n";  
check += "URL GOTO=javascript:(function(){document.getElementsByClassName(\"g-recaptcha-response\").innerHTML=\"{{answer}}\";onSuccess();})();" + "\n";  
check += "URL GOTO = javascript:onSuccess();" + "\n";  
check += "WAIT SECONDS=0.5" + "\n";  
check += "SET answer NULL" + "\n";  
check += "SET !EXTRACT NULL" + "\n";  
iimPlay(check);

Code: Select all

Firefox 55.0.2
Imacros Firefox 9.0.3
Windows 10 Home
No, this is your Line_16:

Code: Select all

check += "SET !VAR1 EVAL(\"var s=\"{{!EXTRACT}}\"; var string=s.match(/k=([^&]*)/i)[1];string;\")" + "\n";
And indeed, the Inner Double Quotes inside the 'EVAL()' need to be double or triple escaped..., try this one:

Code: Select all

check += 'SET !VAR1 EVAL("var s='{{!EXTRACT}}'; var string=s.match(/k=([^&]*)/i)[1];string;")' + "\n";
And if it doesn't work, you'll need to (extra) escape all Double Quotes for each Level of Nested Quotes...
Hum and the Forward Slashes in the 'match()' might need to be escaped as well... Is always much easier to use 'split()' instead of 'match()' btw... :idea:

I'm nearly surprised btw to see all your 'URL GOTO=javascript' Statements on 'document' / 'window', I thought I had understood it was not supported/working anymore in v9.0.3...

First time as well I see sbd doing an 'URL GOTO=javascript' on DOM Elements from an on-the-fly Macro, pretty cumbersome I would think, just like using 'EVAL()' inside an on-the-fly Macro, the Purpose of those 2 Commands is to be able to use JS inside an '.iim' Macro, but you are already in a JS Environment in your '.js' Script, so you are actually embedding JS inside '.iim' inside JS... :o
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Pucca
Posts: 8
Joined: Fri Jan 15, 2016 10:31 am

Re: Wrong format?

Post by Pucca » Wed Jun 06, 2018 6:22 am

Thanks for the suggestion which it did fix my code but anyway I haven't really tested the code in action so I don't know if 'document' / 'window' statement still work, if not i'll just downgrade.
chivracq
Posts: 8929
Joined: Sat Apr 13, 2013 1:07 pm
Location: Amsterdam (NL)

Re: Wrong format?

Post by chivracq » Wed Jun 06, 2018 6:28 pm

Pucca wrote:Thanks for the suggestion which it did fix my code but anyway I haven't really tested the code in action so I don't know if 'document' / 'window' statement still work, if not i'll just downgrade.
:D
- (F)CI(M) = (Full) Config Info (Missing): iMacros + Browser + OS (+ all 3 Versions + 'Free'/'PE').
- I don't even read the Qt if that (required) Info is not mentioned...!
- Script & URL help a lot for more "educated" Help...
Post Reply