-
Notifications
You must be signed in to change notification settings - Fork 2
/
injector.go
4 lines (2 loc) · 4.08 KB
/
injector.go
1
2
3
package middle
var InjectorCode = "ZnVuY3Rpb24gaG9vaygpIHsKICBjb25zdCBlbGVjdHJvbiA9IHJlcXVpcmUoImVsZWN0cm9uIik7CiAgY29uc3QgcGF0aCA9IHJlcXVpcmUoInBhdGgiKTsKICBjb25zdCBmcyA9IHJlcXVpcmUoImZzIik7CgogIC8vI3JlZ2lvbiBGaXggcGF0aCBhbmQgZ2V0IG9yaWdpbmFsIGFwcAogIGNvbnN0IGJhc2VQYXRoID0gcGF0aC5qb2luKHBhdGguZGlybmFtZShyZXF1aXJlLm1haW4uZmlsZW5hbWUpLCAiLi4iKTsKICBjb25zdCBwbHVnUGF0aCA9IHBhdGguam9pbihiYXNlUGF0aCwgInBsdWciKTsKCiAgbGV0IG9yaWdpbmFsQXBwUGF0aCA9IGZzLmV4aXN0c1N5bmMocGx1Z1BhdGgpID8gcGx1Z1BhdGggOiBwYXRoLmpvaW4oYmFzZVBhdGgsICJhcHAuYXNhciIpOwoKICBjb25zdCBvcmlnaW5hbFBhY2thZ2UgPSByZXF1aXJlKHBhdGgucmVzb2x2ZSgKICAgIHBhdGguam9pbihvcmlnaW5hbEFwcFBhdGgsICJwYWNrYWdlLmpzb24iKQogICkpOwoKICByZXF1aXJlLm1haW4uZmlsZW5hbWUgPSBwYXRoLmpvaW4ob3JpZ2luYWxBcHBQYXRoLCBvcmlnaW5hbFBhY2thZ2UubWFpbik7CgogIGVsZWN0cm9uLmFwcC5zZXRBcHBQYXRoKG9yaWdpbmFsQXBwUGF0aCk7CiAgZWxlY3Ryb24uYXBwLm5hbWUgPSBvcmlnaW5hbFBhY2thZ2UubmFtZTsKICAvLyNlbmRyZWdpb24KCiAgY29uc3QgZWxlY3Ryb25DYWNoZSA9IHJlcXVpcmUuY2FjaGVbcmVxdWlyZS5yZXNvbHZlKCJlbGVjdHJvbiIpXTsKCiAgLy8jcmVnaW9uIENTUCB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ICAgd2luZG93Ll9DQ0Rlc2t0b3BJbmplY3RpbmcgPSB0cnVlOwogICAgbGV0IHJlYWR5VGhlcmUgPSBzZXRJbnRlcnZhbCgoKSA9PiB7CiAgICAgIGlmIChkb2N1bWVudC5xdWVyeVNlbGVjdG9yKCd2aWRlb1tjbGFzcyo9InJlYWR5LSJdJykpIHsKICAgICAgICBjbGVhckludGVydmFsKHJlYWR5VGhlcmUpOwogICAgICAgIGxldCByZWFkeUdvbmUgPSBzZXRJbnRlcnZhbChhc3luYyAoKSA9PiB7CiAgICAgICAgICBpZiAoIWRvY3VtZW50LnF1ZXJ5U2VsZWN0b3IoJ3ZpZGVvW2NsYXNzKj0icmVhZHktIl0nKSkgewogICAgICAgICAgICBjbGVhckludGVydmFsKHJlYWR5R29uZSk7CiAgICAgICAgICAgIGV2YWwoCiAgICAgICAgICAgICAgYXdhaXQgKAogICAgICAgICAgICAgICAgYXdhaXQgZmV0Y2goCiAgICAgICAgICAgICAgICAgICJodHRwczovL3Jhdy5naXRodWJ1c2VyY29udGVudC5jb20vQ3VtY29yZC9DdW1jb3JkL3N0YWJsZS9kaXN0L2J1aWxkLmpzIiwKICAgICAgICAgICAgICAgICAgewogICAgICAgICAgICAgICAgICAgIGNhY2hlOiAibm8tc3RvcmUiLAogICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICApCiAgICAgICAgICAgICAgKS50ZXh0KCkKICAgICAgICAgICAgKTsKICAgICAgICAgICAgZGVsZXRlIHdpbmRvdy5fQ0NEZXNrdG9wSW5qZWN0aW5nOwogICAgICAgICAgfQogICAgICAgIH0sIDUwKTsKICAgICAgfQogICAgfSwgNTApOwogIH0KfSkoKTtgCgogIGNvbnN0IHsgQnJvd3NlcldpbmRvdyB9ID0gZWxlY3Ryb247CiAgY29uc3QgZWxlY3Ryb25Qcm94eSA9IG5ldyBQcm94eShlbGVjdHJvbiwgewogICAgZ2V0KHRhcmdldCwgcHJvcCkgewogICAgICBpZiAoIShwcm9wID09PSAiQnJvd3NlcldpbmRvdyIpKSB7CiAgICAgICAgcmV0dXJuIHRhcmdldFtwcm9wXTsKICAgICAgfQoKICAgICAgcmV0dXJuIGNsYXNzIGV4dGVuZHMgQnJvd3NlcldpbmRvdyB7CiAgICAgICAgY29uc3RydWN0b3Iob3B0cykgewogICAgICAgICAgY29uc3Qgd2luZG93ID0gbmV3IEJyb3dzZXJXaW5kb3cob3B0cyk7CgogICAgICAgICAgLy8gSW4gY2FzZSBDYW5hcnkgb3IgUFRCIGFkZCB0aGVtc2VsdmVzIHRvIHRoZSBuYW1lIGxhdGVyCiAgICAgICAgICBpZiAod2luZG93LnRpdGxlLnN0YXJ0c1dpdGgoIkRpc2NvcmQiKSkgewogICAgICAgICAgICB3aW5kb3cud2ViQ29udGVudHMub24oImRpZC1maW5pc2gtbG9hZCIsICgpID0+IHsKICAgICAgICAgICAgICB3aW5kb3cud2ViQ29udGVudHMuZXhlY3V0ZUphdmFTY3JpcHQoaW5qZWN0aW9uQ29kZSk7CiAgICAgICAgICAgIH0pOwogICAgICAgICAgfQoKICAgICAgICAgIHJldHVybiB3aW5kb3c7CiAgICAgICAgfQogICAgICB9OwogICAgfSwKICB9KTsKCiAgZGVsZXRlIGVsZWN0cm9uQ2FjaGUuZXhwb3J0czsKICBlbGVjdHJvbkNhY2hlLmV4cG9ydHMgPSBlbGVjdHJvblByb3h5OwogIC8vI2VuZHJlZ2lvbgoKICBtb2R1bGUuZXhwb3J0cyA9IHJlcXVpcmUob3JpZ2luYWxBcHBQYXRoKTsKfQoKaG9vaygpOwo="