Instantly share code, notes, and snippets.

@englehardt /forter-snippet.md Secret
Last active Apr 11, 2018

Embed
What would you like to do?
No boundaries: Snippet from Forter script (https://gist.github.com/englehardt/2c60a9d60ac1edfdb52b3455eca21de0)

Cleaned up snippet. x() prepares a message w/ timestamp and useragent.

  • Calls FB.getLoginStatus and grabs the userID if available.
  if (window["FB"]) {
    r["dIsAPIAvailable"] = true;
    if (window["FB"]["getLoginStatus"]) {
      window["FB"]["getLoginStatus"](function(j) {
        if (j["status"] === "connected") {
          r["dUsrId"] = j["authResponse"]["userID"];
          r["dIsLoggedInF"] = true;
          r["dIsAppAuthorized"] = true;
        } else if (j["status"] === "not_authorized") {
          r["dIsLoggedInF"] = true;
          r["dIsAppAuthorized"] = false;
        } else {
          r["dIsLoggedInF"] = false;
          r["dIsAppAuthorized"] = false;
        }
        x();
      });
    }
  } else {
    r["dIsAPIAvailable"] = false;
    x();
  }

Seems to access the Google API via data stored in the global variable window['__jsl']. You can see this variable being written in the original Google plus script https://apis.google.com/js/plusone.js.

() {
  try {
    var f = {
      dIsAPIAvailable: "NA",
      dType: "NA",
      dLang: "NA",
      dIsLoggedInG: "NA",
      dIsGPlUser: "NA"
    };
    if (!!window["___jsl"] && !!window["___jsl"]["cfg"]) {
      f["dIsAPIAvailable"] = true;
      f["dType"] = window["___jsl"]["cfg"]["deviceType"];
      f["dLang"] = window["___jsl"]["cfg"]["llang"];
      f["dIsLoggedInG"] = window["___jsl"]["cfg"]["isLoggedIn"];
      f["dIsGPlUser"] = window["___jsl"]["cfg"]["isPlusUser"];
    } else {
      f["dIsAPIAvailable"] = false;
    }
    V({
      "start": G2,
      "end": new Date()[O]();
      "action": G,
      "url": (location["href"] || "")["substring"](L4h.K, 2000),
      "userAgent": navigator["userAgent"],
      "text": ftr__JSON3["stringify"](f)
    });
  } catch (A) {
    E("error in ext " + G + " (run) [" + X + "]", A);
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment