google +1 javascript configuration object

眉间皱痕 提交于 2019-12-03 06:05:16

Widget script run at document.scripts and searching one with string "/js/plusone.js" in scr attribute. After this trim string and create anonymous function. Result of it is object with configuration properties.

if (Gb[u] > 0) {
    for (var Hb = "", Ib = 0; Ib < Gb[u]; Ib++) {
        var Jb = Gb[Ib][nb]("src");
        Jb && Jb[q]("/js/plusone.js") != -1 && (Hb = Q.d.rb(Gb[Ib]));
    }
    Hb = Hb[Ea](/^\s+|\s+$/g, "");
    Hb[q]("{") != 0 && (Hb = "{" + Hb + "}");
    try {
        var Kb = (new Function("return (" + Hb + "\n)"))(), Mb;
        for (Mb in Kb) i.__GOOGLEAPIS.gwidget[Mb] = Kb[Mb];
    } catch (Nb) {}
}

As the google source is obfuscated I don't know how they do it. How I would do it is use JQuery to find the tag and then use .innerHTML to get this as a string then use JSON.parse to parse the object safely.

<script ...>
 {"lang" : "de"}
</script>
...
var data= JSON.parse(
    $('script[src="https://apis.google.com/js/plusone.js"]')[0].innerHTML)
alert(data.lang)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!