function chrome_step(method,params) {chrome_id++;
if (chrome_id == 1) chrome_handshake(); // handshake on first call
var chrome_intent = JSON.stringify({'id': chrome_id, 'method': method, 'params': params});
if (chrome_targetid !== '') chrome_intent = JSON.stringify({'id': chrome_id, 'method': 'Target.sendMessageToTarget', 'params': {'targetId': chrome_targetid, 'message': chrome_intent}}); // send as message to target if context is popup
var fs = require('fs'); fs.write('tagui_chrome.in','['+chrome_id.toString()+'] '+chrome_intent,'w');
var chrome_result = ''; do {sleep(100); chrome_result = fs.read('tagui_chrome.out').trim();}
while (chrome_result.indexOf('['+chrome_id.toString()+'] ') == -1);
if (chrome_targetid == '') return chrome_result.substring(chrome_result.indexOf('] ')+2); // below for handling popup
else {try {var raw_json_string = JSON.stringify(JSON.parse(chrome_result.substring(chrome_result.indexOf('] ')+2)).params.message); return raw_json_string.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\n/g,"\\n");} catch(e) {return '';}}}
// php helper process tagui_chrome.php running to handle this concurrently
php helper process tagui_chrome.php running to handle this concurrently
php helper process tagui_chrome . php running to handle this concurrently
function chrome_step(method,params) {chrome_id++;
if (chrome_id == 1) chrome_handshake(); 
var chrome_intent = JSON.stringify({'id': chrome_id, 'method': method, 'params': params});
if (chrome_targetid !== '') chrome_intent = JSON.stringify({'id': chrome_id, 'method': 'Target.sendMessageToTarget', 'params': {'targetId': chrome_targetid, 'message': chrome_intent}}); 
var fs = require('fs'); fs.write('tagui_chrome.in','['+chrome_id.toString()+'] '+chrome_intent,'w');
var chrome_result = ''; do {sleep(100); chrome_result = fs.read('tagui_chrome.out').trim();}
while (chrome_result.indexOf('['+chrome_id.toString()+'] ') == -1);
if (chrome_targetid == '') return chrome_result.substring(chrome_result.indexOf('] ')+2); 
else {try {var raw_json_string = JSON.stringify(JSON.parse(chrome_result.substring(chrome_result.indexOf('] ')+2)).params.message); return raw_json_string.slice(1,-1).replace(/\\"/g,'"').replace(/\\\\n/g,"\\n");} catch(e) {return '';}}}
function chrome_step ( method , params ) { chrome_id ++ ; if ( chrome_id == 1 ) chrome_handshake ( ) ; var chrome_intent = JSON . stringify ( { 'id' : chrome_id , 'method' : method , 'params' : params } ) ; if ( chrome_targetid !== '' ) chrome_intent = JSON . stringify ( { 'id' : chrome_id , 'method' : 'Target.sendMessageToTarget' , 'params' : { 'targetId' : chrome_targetid , 'message' : chrome_intent } } ) ; var fs = require ( 'fs' ) ; fs . write ( 'tagui_chrome.in' , '[' + chrome_id . toString ( ) + '] ' + chrome_intent , 'w' ) ; var chrome_result = '' ; do { sleep ( 100 ) ; chrome_result = fs . read ( 'tagui_chrome.out' ) . trim ( ) ; } while ( chrome_result . indexOf ( '[' + chrome_id . toString ( ) + '] ' ) == - 1 ) ; if ( chrome_targetid == '' ) return chrome_result . substring ( chrome_result . indexOf ( '] ' ) + 2 ) ; else { try { var raw_json_string = JSON . stringify ( JSON . parse ( chrome_result . substring ( chrome_result . indexOf ( '] ' ) + 2 ) ) . params . message ) ; return raw_json_string . slice ( 1 , - 1 ) . replace ( / \\" / g , '"' ) . replace ( / \\\\n / g , "\\n" ) ; } catch ( e ) { return '' ; } } }
php helper process tagui_chrome.php running to handle this concurrently
php helper process tagui_chrome . php running to handle this concurrently
// handshake on first call // send as message to target if context is popup // below for handling popup