Use JavaScripts methods on C# - c#

I'm download web page and parse javascript code, which have in code hash and java decode function...
please I want to call javascript decode method from C# program...
In web page I've :
window.decoded_hashes = {};
window.decodehash = function(hash) {
window.dec_hash(hash);
return window.decoded_hashes[hash];
window.dec_hash = function(hash) {
(function(__){window.decoded_hashes[hash] = _(__,8,_____(__)-12)+_(__,0,5);})((function(__){____='';for(___=0;___<_____(__);++___)____+=______(__,_____(__)-___-1);return window[_______(88,11,-13)]?__:____;})((function(__){____=window[_______(103,-2)]?'':'____';for(___=0;___<_____(__);++___)____+=(function(__){return __>111?(121-__):_______(__);})(__.charCodeAt(___));return ____;})((function(__){_______=function(){var _='',__=0,___=arguments;for(var ____=0;____<___.length;++____)_+=String.fromCharCode(__+=___[____]);return _;};______=function(__,___){return __.charAt(___);};_____=function(__){return __.length;};____=(_=function(_,__,___){____='';(___=___?___:(_____(_)-__));for(;___;--___)____+=(function(_,__){return ______(_,__)})(_,__++);return ____;})(__,3,3);____+=_(__,0,2)+_(__,8);return ____;})(hash))));
}
window.wall_post_hash = decodehash('tsucuqtyqvedvvpruuqasavdpwdcxafcystrdfvsyd');
And I must sent decode hash on server... hash in () - dinamic
How to make easier? I've found Rhino and IKVM, but have not understood yet...
Give me advice Pls...
Sorry for my English;)

You could include Microsoft.JScript in your project references.
Check out an example from Rick Strahl's on how you can use Eval to get your results.
Here's an implementation I managed to work out after some debugging and changes. It returns the same result as your example. One issue is that .Net don't seem to work with the function "arguments" variable. So I added 5 variables to that function to get it to work. Seems the most which is passed is 3.
package Pack
{
class JSEval
{
public function MyEval(inputhash : String) : String
{
var ___ = 0;
var _= '';
var ____ = '';
var _______;
var ______;
var _____;
var ____ = (_ = function(_, __, ___) {
____ = '';
(___ = ___ ? ___ : (_____(_) - __));
for (; ___; --___) ____ += (function(_, __) {
return ______(_, __)
})(_, __++);
return ____;
})
var mywin = new Object();
mywin.decoded_hashes = {};
mywin.dec_hash = function(hash) {
(function(__) {
mywin.decoded_hashes[hash] = _(__, 8, _____(__) - 12) + _(__, 0, 5);
})((function(__) {
var ____ = '';
for (___ = 0; ___ < _____(__); ++___) ____ += ______(__, _____(__) - ___ - 1);
return mywin[_______(88, 11, -13)] ? __ : ____;
})((function(input) {
var res = mywin[_______(103, -2)] ? '' : '____';
for (var i = 0; i < _____(input); ++i) res += (function(input) {
return input > 111 ? (121 - input) : _______(input);
})(input.charCodeAt(i));
return res;
})((function(__) {
_______ = function(a,b,c,d,e) {
var arguments = new Array();
if( a != undefined )
arguments.push(a);
if( b != undefined )
arguments.push(b);
if( c != undefined )
arguments.push(c);
if( d != undefined )
arguments.push(d);
if( e != undefined )
arguments.push(e);
var _ = '';
var __ = 0;
for (var i = 0; i < arguments.length; ++i) _ += String.fromCharCode(__ += arguments[i]);
return _;
};
______ = function(__, ___) {
return __.charAt(___);
};
_____ = function(__) {
return __.length;
};
____ = (_ = function(_, __, ___) {
____ = '';
(___ = ___ ? ___ : (_____(_) - __));
for (; ___; --___) ____ += (function(_, __) {
return ______(_, __)
})(_, __++);
return ____;
})(__, 3, 3);
____ += _(__, 0, 2) + _(__, 8);
return ____;
})(hash))));
}
mywin.decodehash = function(hash) {
mywin.dec_hash(hash);
return mywin.decoded_hashes[hash];
}
return mywin.decodehash(inputhash);
}
}
}

Related

How to parse nested parenthesis only in first level in C#

I would like to write C# code that parses nested parenthesis to array elements, but only on first level. An example is needed for sure:
I want this string:
"(example (to (parsing nested paren) but) (first lvl only))"
tp be parsed into:
["example", "(to (parsing nested paren) but)", "(first lvl only)"]
I was thinking about using regex but can't figure out how to properly use them without implementing this behaviour from scratch.
In the case of malformed inputs I would like to return an empty array, or an array ["error"]
I developed a parser for your example. I also checked some other examples which you can see in the code.
using System;
using System.Collections;
using System.Collections.Generic;
public class Program
{
public static void Main()
{
string str = "(example (to (parsing nested paren) but) (first lvl only))"; // => [example , (to (parsing nested paren) but) , (first lvl only)]
//string str = "(first)(second)(third)"; // => [first , second , third]
//string str = "(first(second)third)"; // => [first , (second) , third]
//string str = "(first(second)(third)fourth)"; // => [first , (second) , (third) , fourth]
//string str = "(first((second)(third))fourth)"; // => [first , ((second)(third)) , fourth]
//string str = "just Text"; // => [ERROR]
//string str = "start with Text (first , second)"; // => [ERROR]
//string str = "(first , second) end with text"; // => [ERROR]
//string str = ""; // => [ERROR]
//string str = "("; // => [ERROR]
//string str = "(first()(second)(third))fourth)"; // => [ERROR]
//string str = "(((extra close pareanthese))))"; // => [ERROR]
var res = Parser.parse(str);
showRes(res);
}
static void showRes(ArrayList res)
{
var strings = res.ToArray();
var theString = string.Join(" , ", strings);
Console.WriteLine("[" + theString + "]");
}
}
public class Parser
{
static Dictionary<TokenType, TokenType> getRules()
{
var rules = new Dictionary<TokenType, TokenType>();
rules.Add(TokenType.OPEN_PARENTHESE, TokenType.START | TokenType.OPEN_PARENTHESE | TokenType.CLOSE_PARENTHESE | TokenType.SIMPLE_TEXT);
rules.Add(TokenType.CLOSE_PARENTHESE, TokenType.SIMPLE_TEXT | TokenType.CLOSE_PARENTHESE);
rules.Add(TokenType.SIMPLE_TEXT, TokenType.SIMPLE_TEXT | TokenType.CLOSE_PARENTHESE | TokenType.OPEN_PARENTHESE);
rules.Add(TokenType.END, TokenType.CLOSE_PARENTHESE);
return rules;
}
static bool isValid(Token prev, Token cur)
{
var rules = Parser.getRules();
return rules.ContainsKey(cur.type) && ((prev.type & rules[cur.type]) == prev.type);
}
public static ArrayList parse(string sourceText)
{
ArrayList result = new ArrayList();
int openParenthesesCount = 0;
Lexer lexer = new Lexer(sourceText);
Token prevToken = lexer.getStartToken();
Token currentToken = lexer.readNextToken();
string tmpText = "";
while (currentToken.type != TokenType.END)
{
if (currentToken.type == TokenType.OPEN_PARENTHESE)
{
openParenthesesCount++;
if (openParenthesesCount > 1)
{
tmpText += currentToken.token;
}
}
else if (currentToken.type == TokenType.CLOSE_PARENTHESE)
{
openParenthesesCount--;
if (openParenthesesCount < 0)
{
return Parser.Error();
}
if (openParenthesesCount > 0)
{
tmpText += currentToken.token;
}
}
else if (currentToken.type == TokenType.SIMPLE_TEXT)
{
tmpText += currentToken.token;
}
if (!Parser.isValid(prevToken, currentToken))
{
return Parser.Error();
}
if (openParenthesesCount == 1 && tmpText.Trim() != "")
{
result.Add(tmpText);
tmpText = "";
}
prevToken = currentToken;
currentToken = lexer.readNextToken();
}
if (openParenthesesCount != 0)
{
return Parser.Error();
}
if (!Parser.isValid(prevToken, currentToken))
{
return Parser.Error();
}
if (tmpText.Trim() != "")
{
result.Add(tmpText);
}
return result;
}
static ArrayList Error()
{
var er = new ArrayList();
er.Add("ERROR");
return er;
}
}
class Lexer
{
string _txt;
int _index;
public Lexer(string text)
{
this._index = 0;
this._txt = text;
}
public Token getStartToken()
{
return new Token(-1, TokenType.START, "");
}
public Token readNextToken()
{
if (this._index >= this._txt.Length)
{
return new Token(-1, TokenType.END, "");
}
Token t = null;
string txt = "";
if (this._txt[this._index] == '(')
{
txt = "(";
t = new Token(this._index, TokenType.OPEN_PARENTHESE, txt);
}
else if (this._txt[this._index] == ')')
{
txt = ")";
t = new Token(this._index, TokenType.CLOSE_PARENTHESE, txt);
}
else
{
txt = this._readText();
t = new Token(this._index, TokenType.SIMPLE_TEXT, txt);
}
this._index += txt.Length;
return t;
}
private string _readText()
{
string txt = "";
int i = this._index;
while (i < this._txt.Length && this._txt[i] != '(' && this._txt[i] != ')')
{
txt = txt + this._txt[i];
i++;
}
return txt;
}
}
class Token
{
public int position
{
get;
private set;
}
public TokenType type
{
get;
private set;
}
public string token
{
get;
private set;
}
public Token(int position, TokenType type, string token)
{
this.position = position;
this.type = type;
this.token = token;
}
}
[Flags]
enum TokenType
{
START = 1,
OPEN_PARENTHESE = 2,
SIMPLE_TEXT = 4,
CLOSE_PARENTHESE = 8,
END = 16
}
well, regex will do the job:
var text = #"(example (to (parsing nested paren) but) (first lvl only))";
var pattern = #"\(([\w\s]+) (\([\w\s]+ \([\w\s]+\) [\w\s]+\)) (\([\w\s]+\))\)*";
try
{
Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
Match m = r.Match(text);
string group_1 = m.Groups[1].Value; //example
string group_2 = m.Groups[2].Value; //(to (parsing nested paren) but)
string group_3 = m.Groups[3].Value; //(first lvl only)
return new string[]{group_1,group_2,group_3};
}
catch(Exception ex){
return new string[]{"error"};
}
hopefully this helps, tested here in dotnetfiddle
Edit:
this might get you started into building the right expression according to whatever patterns you are falling into and maybe build a recursive function to parse the rest into the desired output :)
RegEx is not recursive. You either count bracket level, or recurse.
An non-recursive parser loop I tested for the example you show is..
string SplitFirstLevel(string s)
{
List<string> result = new List<string>();
int p = 0, level = 0;
for (int i = 0; i < s.Length; i++)
{
if (s[i] == '(')
{
level++;
if (level == 1) p = i + 1;
if (level == 2)
{
result.Add('"' + s.Substring(p, i - p) + '"');
p = i;
}
}
if (s[i] == ')')
if (--level == 0)
result.Add('"' + s.Substring(p, i - p) + '"');
}
return "[" + String.Join(",", result) + "]";
}
Note: after some more testing, I see your specification is unclear. How to delimit orphaned level 1 terms, that is terms without bracketing ?
For example, my parser translates
(example (to (parsing nested paren) but) (first lvl only))
to:
["example ","(to (parsing nested paren) but) ","(first lvl only)"]
and
(example (to (parsing nested paren)) but (first lvl only))
to:
["example ","(to (parsing nested paren)) but ","(first lvl only)"]
In either case, "example" gets a separate term, while "but" is grouped with the first term. In the first example this is logical, it is in the bracketing, but it may be unwanted behaviour in the second case, where "but" should be separated, like "example", which also has no bracketing (?)

How to get value from list string?

The return result of string list is :
var result= "1,red,2,blue,3,green,4,orange";
I want to use a loop and get result like 1,2,3,4 and red,blue,green,orange
My code is as below.
I got the error in split.
Object does not support for split().
I am using jquery 1.10.1 .
$.ajax({
type: "GET",
url: "/_vti_bin/userService/myservice.svc/GetUserListForMentionSign?query" + query,
async: false,
dataType: "JSON",
cache: false,
processdata: true,
success: function (result) {
data = result;
//arrary
var resultArray = data.Split(',');
var id = new Array(), name = new Array();
$.each(resultArray, function (index, value) {
if (isNaN(value)) {
name.push(value);
alert(name.push(value));
}
else {
id.push(value);
}
});
Here is the web service for c#.
public List<string> GetUserListForMentionSign(string username)
{
List<User> UserList = new List<User>();
List<string> returnvalue=new List<string>();
try
{
string returnstring = string.Empty;
DataTable dt = null;
dt = Library.Helper.FindUser(username, 200);
foreach (DataRow dr in dt.Rows)
{
if (dr["Title"].ToString() != "Person.aspx") // those user without the name
{
User user = new User();
user.id = dr["ID"].ToString();
user.name = dr["Name"].ToString();
UserList.Add(spuser);
}
}
}
catch (Exception ex)
{
}
return UserList.Select(a=>new[]{ a.name.ToString(),a.id.ToString()}).SelectMany(a=>a).ToList();
}
You can use jQuery map function to create 2 different arrays containing even and odd indexed values and manipulate it
var result = "1,red,2,blue,3,green,4,orange";
var arr=result.split(',');
var odd = jQuery.map( arr, function(n,i){
return i%2 ? n : null;
});
var even = jQuery.map( arr, function(n,i){
return i%2 ? null : n;
});
Try this : Use .split() to convert string into array and then iterate array. Inside loop check if value is number of not using isNaN() and push values to respective array.
var result= "1,red,2,blue,3,green,4,orange";
var resultArray = result.split(",");
var numberArray = new Array(), colorArray = new Array();
$.each(resultArray , function( index, value ) {
if(isNaN(value))
colorArray.push(value);
else
numberArray.push(value);
});
alert(colorArray.toString());
alert(numberArray.toString());
try
var result = "1,red,2,blue,3,green,4,orange";
var splitValue = result.split(",");
var num = [];
var str = [];
for (var i in splitValue) {
if (i % 2 === 0) {
num.push(splitValue[i]);
} else {
str.push(splitValue[i]);
}
}
console.log(num);
console.log(str);
In C language I have implemented like this.
Logic: input is parsed to split num&strings and stored to different array. At the end result array is printed.
int main()
{
char *str, result []= "1,red,2,blue,3,green,4,orange";
char *p, *p1;
char num[10], i=0;
char name[10][15], j=0,k;
str =result;
while (1)
{
p= strchr (str, ',');
if(!p1)
break;
num [i]=atoi (p-1) ;
i++;
p1= strchr (p+1, ',');
if(!p1){
strcpy ( name[j], p+1);
j++;
break;
}
p1[0]='\0';
strcpy ( name[j], p+1);
j++;
str=p1+1;
}
for (k=0; k<i; ++k){
printf ( "%d ", num[k]);
}
printf ("\n");
for (k=0; k<j; ++k){
printf ( "%s ", name[k]);
}
printf ("\n");
}
var result= "1,red,2,blue,3,green,4,orange";
string[] arr = result.Split(',');
int[] num;
string[] text;
foreach(var i in arr)
{
int cont;
if (int.TryParse(i, out cont) == false)
text[] = i;
else
num[] = cont;
}
or loop manually
for(int i = 0; i < arr.lenght; i++)
{
int cont;
if (int.TryParse(arr[i], out cont) == false)
text[i] = i;
else
num[i] = cont;
}
note : splitting from server side for C#.

How would you time out multiple async requests with Scala's async?

I don't know Scala but I am curious about its async feature (similar to C#'s). How would you translate this go code into Scala async?
http://talks.golang.org/2012/concurrency.slide#47
c := make(chan Result)
go func() { c <- Web(query) } ()
go func() { c <- Image(query) } ()
go func() { c <- Video(query) } ()
timeout := time.After(80 * time.Millisecond)
for i := 0; i < 3; i++ {
select {
case result := <-c:
results = append(results, result)
case <-timeout:
fmt.Println("timed out")
return
}
}
return
Here's a sketch of how it could be done (untested; I make no claim that this is the best solution):
// I assume that the Web/Image/Video functions return instances of Future[Result]
val f1 = Web(query)
val f2 = Image(query)
val f3 = Video(query)
val t = timeout(80.milliseconds)
// using Scala's Future API
val results: Future[Seq[Result]] = for {
r1 <- or(f1)(t)
r2 <- or(f2)(t)
r3 <- or(f3)(t)
} yield (r1.toSeq ++ r2.toSeq ++ r3.toSeq)
// OR using async
val results: Future[Seq[Result]] = async {
val r1 = or(f1)(t)
val r2 = or(f2)(t)
val r3 = or(f3)(t)
await(r1).toSeq ++ await(r2).toSeq ++ await(r3).toSeq
}
// or and timeout are utility/library functions defined below
def or[T](f1: Future[T])(f2: Future[Option[Nothing]]): Future[Option[T]] =
Future.firstCompletedOf(f1 map Some.apply, f2)
// create a future that will complete successfully with None
// after the given duration passes
def timeout(d: Duration): Future[Option[Nothing]] = {
val p = Promise[Option[Nothing]]
Scheduler.after(d) { p success None }
p.future
}

Multiple querying of a mongodb using node

I can't seem to find a proper answer to my question, I have looked all over stackoverflow.
Consider a sample code in C# which I'm trying to port to nodejs + mongobd.
var messageList = new List<MessageHelper>();
foreach( MessageActivation messageToAsk in messagesToAsk )
{
var message = from m in dbContext.Messages where m.Id == messageToAsk.MessageId select m;
var jokeMessage = from m in dbContext.Messages where m.Id == messageToAsk.JokeMessageId select m;
var user = from u in dbContext.Users where u.Id == messageToAsk.SourceUserId select u;
var messageHelper = new MessageHelper();
messageHelper.AskingUserId = user.ToList()[0].Id;
messageHelper.Message = message.ToList()[0];
messageList.Add( messageHelper );
}
return messageList;
What is the best way to do that in node's way ? Just a side node, dbContext will query the DB. The point is to collect all the needed infos, package it and only then send it.
Thanks
EDIT:
This is what I have tried
// collect needed info to make next queries in db
var messageIdList = new Array();
var jokeMessageIdList = new Array();
var sourceUserIdList = new Array();
for( var i=0; i < messagesToAsk.length; i++ )
{
messageIdList.push( messagesToAsk[i].MessageId );
jokeMessageIdList.push( jokeMessageId[i].JokeMessageId );
sourceUserIdList .push( jokeMessageId[i].SourceUserId );
}
// make requests to have all the data in place
var messages = App.DataModels.Messages.find( {} );
messages.where( 'MessageId' ).in( messageIdList );
messages.exec( function ( err, foundMessages )
{
var jokeMessages = App.DataModels.Messages.find( {} );
jokeMessages.where( 'JokeMessageId' ).in( jokeMessageIdList );
jokeMessages.exec( function ( err, foundJokeMessages )
{
var users = App.DataModels.Messages.find( {} );
users.where( 'SourceUserId' ).in( sourceUserIdList );
users.exec( function ( err, foundUsers )
{
var messageList = new Array(); // new List<MessageHelper>();
for( var i=0; i < messagesToAsk.length; i++ )
{
var message = null;
var jokeMessage = null;
var user = null;
// get the data
for( var j = 0; j < messages.length; j++ )
{
if( messages[j].MessageId === messagesToAsk[i].MessageId )
{
message = messages[j];
break;
}
}
for( var k = 0; k < jokeMessages.length; k++ )
{
if( jokeMessages[k].JokeMessageId === messagesToAsk[k].JokeMessageId )
{
jokeMessage = jokeMessage[k];
break;
}
}
for( var l = 0; l < users.length; l++ )
{
if ( users[l].SourceUserId === messagesToAsk[l].SourceUserId )
{
user = users[l];
break;
}
}
var messageHelper =
{
"AskingUserId" : user.Id,
"AskingUserPic" : user.HelperPhoto,
"Message" : message,
"JokeMessage" : message.Type === "1" ? jokeMessage.Content
};
messageList.Add( messageHelper );
}
responseDelegate( response, messageList );
});
});
});
I post it here for some one else who is making the shift.
The idea seems to be that you need to have all the data already collected and filtered before you start iterating and assembling any final result to send over.
Answering my question in the context of having an analogy of C#/Linq DB queries to NodeJS/Mongo. A kind of mapping of the "thinking" way. This is mostly just to understand the shift. A proper implementation would be to use patterns(library) like Promise/Deffered as suggested in the comments to the question by #WiredPrairie.
// collect needed info to make next queries in db
var messageIdList = new Array();
var jokeMessageIdList = new Array();
var sourceUserIdList = new Array();
for( var i=0; i < messagesToAsk.length; i++ )
{
messageIdList.push( messagesToAsk[i].MessageId );
jokeMessageIdList.push( jokeMessageId[i].JokeMessageId );
sourceUserIdList .push( jokeMessageId[i].SourceUserId );
}
// make requests to have all the data in place
var messages = App.DataModels.Messages.find( {} );
messages.where( 'MessageId' ).in( messageIdList );
messages.exec( function ( err, foundMessages )
{
var jokeMessages = App.DataModels.Messages.find( {} );
jokeMessages.where( 'JokeMessageId' ).in( jokeMessageIdList );
jokeMessages.exec( function ( err, foundJokeMessages )
{
var users = App.DataModels.Messages.find( {} );
users.where( 'SourceUserId' ).in( sourceUserIdList );
users.exec( function ( err, foundUsers )
{
var messageList = new Array(); // new List<MessageHelper>();
for( var i=0; i < messagesToAsk.length; i++ )
{
var message = null;
var jokeMessage = null;
var user = null;
// get the data
for( var j = 0; j < messages.length; j++ )
{
if( messages[j].MessageId === messagesToAsk[i].MessageId )
{
message = messages[j];
break;
}
}
for( var k = 0; k < jokeMessages.length; k++ )
{
if( jokeMessages[k].JokeMessageId === messagesToAsk[k].JokeMessageId )
{
jokeMessage = jokeMessage[k];
break;
}
}
for( var l = 0; l < users.length; l++ )
{
if ( users[l].SourceUserId === messagesToAsk[l].SourceUserId )
{
user = users[l];
break;
}
}
var messageHelper =
{
"AskingUserId" : user.Id,
"AskingUserPic" : user.HelperPhoto,
"Message" : message,
"JokeMessage" : message.Type === "1" ? jokeMessage.Content
};
messageList.Add( messageHelper );
}
responseDelegate( response, messageList );
});
});
});

Youtube login using c#

I want to login youtube using c#. I am using HttpWebRequest.
Procedure I am following:
load the login page using GET and parse GALX value
POST username/password along with GALX
get a meta refresh page, parse the url and load using GET
in every step cookies are handled using CookieContainer
UserAgent, ContentType etc header values are set and AllowAutoRedirect is true.
now i am getting the following Javascript code as response.
var Ga, G = G || {};
G.a = { g: "cookie_missing", f: "cookie_found", h: "gaia_failure" };
var Gb = /\s*;\s*/;
var Gc = function () {
try
{
return new XMLHttpRequest
}
catch (a)
{
for (var b = ["MSXML2.XMLHTTP.6.0", "MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP", "Microsoft.XMLHTTP"], c = 0; c < b.length; c++)
try
{
return new ActiveXObject(b[c])
}
catch (d) { }
}
return null
},
Gd = function () {
this.d = Gc(); this.b = {}
};
Gd.prototype.oncomplete = function () { };
Gd.prototype.send = function (a) {
var b = [], c;
for (c in this.b) {
var d = this.b[c];
b.push(c + "=" + encodeURIComponent(d))
}
var b = b.join("&"), e = this.d, f = this.oncomplete;
e.open("POST", a, !0);
e.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
e.setRequestHeader("Content-length", "" + b.length);
e.onreadystatechange = function () {
4 == e.readyState && f({ status: e.status, text: e.responseText })
};
e.send(b)
};
Gd.prototype.get = function (a) {
var b = this.oncomplete, c = this.d; c.open("GET", a, !0);
c.onreadystatechange = function () { 4 == c.readyState && b({ status: c.status, text: c.responseText }) };
c.send()
};
var Gf = function (a) {
this.c = a; this.i = this.j();
if (null == this.c) throw new Ge("Empty module name");
};
Ga = Gf.prototype;
Ga.j = function () {
var a = window.location.pathname;
return a && 0 == a.indexOf("/accounts") ? "/accounts/JsRemoteLog" : "/JsRemoteLog"
};
Ga.k = function (a, b, c) {
for (var d = this.i, e = this.c || "", d = d + "?module=" + encodeURIComponent(e), a = a || "", d = d + "&type=" + encodeURIComponent(a), b = b || "", d = d + "&msg=" + encodeURIComponent(b), c = c || [], a = 0; a < c.length; a++) d = d + "&arg=" + encodeURIComponent(c[a]);
try {
var f = Math.floor(1E4 * Math.random()), d = d + "&r=" + ("" + f)
}
catch (g) { }
return d
};
Ga.send = function (a, b, c) {
var d = new Gd; d.b = {};
try {
var e = this.k(a, b, c);
d.get(e)
} catch (f) { }
};
Ga.error = function (a, b) {
this.send("ERROR", a, b)
};
Ga.warn = function (a, b) {
this.send("WARN", a, b)
};
Ga.info = function (a, b) {
this.send("INFO", a, b)
};
Ga.m = function (a) {
var b = this;
return function () {
try {
return a.apply(null, arguments)
}
catch (c) {
throw b.error("Uncatched exception: " + c), c;
}
}
};
var Ge = function () { };
G = G || {};
G.e = G.e || new Gf("report_sid_status");
G.l = function (a, b, c) {
if (window.postMessage && window.parent) {
if (a) {
a:
{
if (document.cookie)
for (var a = b + "=", b = document.cookie.split(Gb), d = 0; d < b.length; d++) {
var e = b[d], e = e.replace(/^\s+/, ""), e = e.replace(/\s+$/, "");
if (0 == e.indexOf(a)) {
a = e.substr(a.length);
break a
}
}
a = null
}
a = null == a ? G.a.g : G.a.f
}
else a = G.a.h; window.parent.postMessage(a, c)
}
};
G_checkSidAndReport = G.e.m(G.l);
G_checkSidAndReport('0', 'SID', 'https:\x2F\x2Faccounts.google.com');
what to do now? Using this procedure I can successfully login Gmail but not youtube. I think javascript is posting to the server but I am unable to figure out actually what is posting.
I am at the same possition in my code from php, if you manage to figure it out please let me know. I think the key is in the following function with these parametters.
G.l=function(a='1',b='SID',c='https:\x2F\x2Faccounts.google.com'){
if(window.postMessage&&window.parent){
if(a){
a:{
if(document.cookie)for(var a=b+"=",b=document.cookie.split(Gb),d=0;
d<
b.length;
d++){
var e=b[d],e=e.replace(/^\s+/,""),e=e.replace(/\s+$/,"");
if(0==e.indexOf(a)){
a=e.substr(a.length);
break a
}
}
a=null
}
a=null==a?G.a.g:G.a.f
}
else a=G.a.h;
window.parent.postMessage(a,c)
}
}

Categories