Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_海角社区上车@base64://Ly8gPT1Vc2VyU2NyaXB0PT0KLy8gQG5hbWUgICAgICAgICDmtbfop5LnpL7ljLrkuIrovaYKLy8gQG5hbWVzcGFjZSAgICBodHRwOi8vdGFtcGVybW9ua2V5Lm5ldC8KLy8gQHZlcnNpb24gICAgICAwLjMxCi8vIEBkZXNjcmlwdGlvbiAg5rW36KeS56S+5Yy66KeG6aKRL+WbvueJhy/lsIHnpoHnlKjmiLfkuLvpobXop6PmnpAKLy8gQGF1dGhvciAgICAgICBoamhqaGoKLy8gQGxpY2Vuc2UgICAgICBNSVQKLy8gQG1hdGNoICAgICAgICAqOi8vKi5oYWlqaWFvLmNvbS8qCi8vIEBpbmNsdWRlICAgICAgICAqOi8vaGoqLmNvbS8qCi8vIEBpY29uICAgICAgICAgaHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS9zMi9mYXZpY29ucz9zej02NCZkb21haW49YmluZy5jb20KLy8gQHJ1bi1hdCAgICAgIGRvY3VtZW50LXN0YXJ0Ci8vIEBncmFudCAgICAgICB1bnNhZmVXaW5kb3cKLy8gQGdyYW50ICAgICAgICBHTV94bWxodHRwUmVxdWVzdAovLyBAY29ubmVjdCAgICAgICoKLy8gPT0vVXNlclNjcmlwdD09CihmdW5jdGlvbiAoKSB7CiAgICAndXNlIHN0cmljdCc7CgogICAgZnVuY3Rpb24gZGVjb2RlKHMpIHsKICAgICAgICByZXR1cm4gYXRvYihhdG9iKGF0b2IocykpKTsKICAgIH0KCiAgICBmdW5jdGlvbiBlbmNvZGUocykgewogICAgICAgIHJldHVybiBidG9hKGJ0b2EoYnRvYShzKSkpOwogICAgfQoKICAgIGZ1bmN0aW9uIGplbmNvZGUocykgewogICAgICAgIHJldHVybiBlbmNvZGUoSlNPTi5zdHJpbmdpZnkocywgYHV0Zi04YCkpOwogICAgfQoKICAgIGZ1bmN0aW9uIGdldF9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T04ucGFyc2UocmVxdWVzdC5yZXNwb25zZVRleHQsIGB1dGYtOGApLmRhdGE7CiAgICAgICAgcCA9IEpTT04ucGFyc2UoZGVjb2RlKHApLCBgdXRmLThgKTsKICAgICAgICBsZXQgdG90YWwgPSBwLnBhZ2UudG90YWw7CiAgICAgICAgbGV0IHVpZCA9IGBbYmFubmVkXWA7CiAgICAgICAgaWYgKGByZXN1bHRzYCBpbiBwKSB7CiAgICAgICAgICAgIHVpZCA9IHAucmVzdWx0c1swXS51c2VyLm5pY2tuYW1lICsgYCBgICsgdWlkOwogICAgICAgIH0KICAgICAgICByZXR1cm4gewogICAgICAgICAgICAnaXNGYXZvcml0ZSc6IGZhbHNlLAogICAgICAgICAgICAnbGlrZUNvdW50JzogMTIsCiAgICAgICAgICAgICd1c2VyJzogewogICAgICAgICAgICAgICAgJ2lkJzogcGFyc2VJbnQoaWQpLAogICAgICAgICAgICAgICAgJ25pY2tuYW1lJzogdWlkLAogICAgICAgICAgICAgICAgJ2F2YXRhcic6ICcyOScsCiAgICAgICAgICAgICAgICAnZGVzY3JpcHRpb24nOiBgaGogY29tbXVuaXR5YCwKICAgICAgICAgICAgICAgICd0b3BpY0NvdW50JzogdG90YWwsCiAgICAgICAgICAgICAgICAndmlkZW9Db3VudCc6IDAsCiAgICAgICAgICAgICAgICAnY29tbWVudENvdW50JzogMzAzLAogICAgICAgICAgICAgICAgJ2ZhbnNDb3VudCc6IDU3LAogICAgICAgICAgICAgICAgJ2Zhdm9yaXRlQ291bnQnOiAzOSwKICAgICAgICAgICAgICAgICdzdGF0dXMnOiAwLAogICAgICAgICAgICAgICAgJ3NleCc6IDEsCiAgICAgICAgICAgICAgICAndmlwJzogMCwKICAgICAgICAgICAgICAgICd2aXBFeHBpcmVzVGltZSc6ICcwMDAxLTAxLTAxIDAwOjAwOjAwJywKICAgICAgICAgICAgICAgICdjZXJ0aWZpZWQnOiBmYWxzZSwKICAgICAgICAgICAgICAgICdjZXJ0VmlkZW8nOiBmYWxzZSwKICAgICAgICAgICAgICAgICdjZXJ0UHJvZmVzc29yJzogZmFsc2UsCiAgICAgICAgICAgICAgICAnZmFtb3VzJzogZmFsc2UsCiAgICAgICAgICAgICAgICAnZm9yYmlkZGVuJzogZmFsc2UsCiAgICAgICAgICAgICAgICAndGFncyc6IG51bGwsCiAgICAgICAgICAgICAgICAncm9sZSc6IDAsCiAgICAgICAgICAgICAgICAncG9wdWxhcml0eSc6IDEwLAogICAgICAgICAgICAgICAgJ2RpYW1vbmRDb25zdW1lJzogMCwKICAgICAgICAgICAgICAgICd0aXRsZSc6IHsgJ2lkJzogMCwgJ25hbWUnOiAnJywgJ2NvbnN1bWUnOiAwLCAnY29uc3VtZUVuZCc6IDAsICdpY29uJzogJycgfSwKICAgICAgICAgICAgICAgICdmcmllbmRTdGF0dXMnOiBmYWxzZSwKICAgICAgICAgICAgICAgICd2b2ljZVN0YXR1cyc6IGZhbHNlLAogICAgICAgICAgICAgICAgJ3ZpZGVvU3RhdHVzJzogZmFsc2UsCiAgICAgICAgICAgICAgICAndm9pY2VNb25leVR5cGUnOiAwLAogICAgICAgICAgICAgICAgJ3ZvaWNlQW1vdW50JzogMCwKICAgICAgICAgICAgICAgICd2aWRlb01vbmV5VHlwZSc6IDAsCiAgICAgICAgICAgICAgICAndmlkZW9BbW91bnQnOiAwLAogICAgICAgICAgICAgICAgJ2RlcG9zaXRNb25leSc6IDAKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KCiAgICBmdW5jdGlvbiByZW1vdmVfdmlwKGJvZHkpIHsKICAgICAgICBib2R5Lm5vZGUudmlwTGltaXQgPSAwOwogICAgICAgIGxldCBhdHRhY2htZW50cyA9IGJvZHkuYXR0YWNobWVudHM7CiAgICAgICAgbGV0IGltYWdlX3VybHMgPSBbXTsKICAgICAgICBsZXQgdmlkZW9fdXJscyA9IGBgOwogICAgICAgIGxldCBoYXNfdmlkZW8gPSAtMTsKICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGF0dGFjaG1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIHZhciBhdHRhID0gYXR0YWNobWVudHNbaV07CiAgICAgICAgICAgIGlmIChhdHRhLmNhdGVnb3J5ID09PSAnaW1hZ2VzJykgewogICAgICAgICAgICAgICAgaW1hZ2VfdXJscy5wdXNoKGA8aW1nIHNyYz0iJHthdHRhLnJlbW90ZVVybH0iIGRhdGEtaWQ9IiR7YXR0YS5pZH0iLz5gKQogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhdHRhLmNhdGVnb3J5ID09PSAndmlkZW8nKSB7CiAgICAgICAgICAgICAgICBoYXNfdmlkZW8gPSBpOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgICAgIGxldCBpbWFnZXMgPSBpbWFnZV91cmxzLmpvaW4oKTsKICAgICAgICBpZiAoaGFzX3ZpZGVvID49IDApIHsKICAgICAgICAgICAgbGV0IFtuYm9keSwgdl0gPSByZXBsYWNlX20zdTgoYm9keSwgaGFzX3ZpZGVvKTsKICAgICAgICAgICAgYm9keSA9IG5ib2R5OwogICAgICAgICAgICB2aWRlb191cmxzID0gYDx2aWRlbyBzcmM9IiR7di5yZW1vdGVVcmx9IiBkYXRhLWlkPSIke3YuaWR9Ii8+PC92aWRlbz5gCiAgICAgICAgfQogICAgICAgIGxldCBjb250ZW50ID0gYm9keS5jb250ZW50LnJlcGxhY2UoL1xbW+WbvueJh+inhumikV0rXF0/LywgYGApOwogICAgICAgIGNvbnRlbnQgPSBib2R5LmNvbnRlbnQucmVwbGFjZSgv5q2k5aSE5YaF5a655ZSu5Lu3Lio/5oKo6L+Y5rKh5pyJ6LSt5Lmw77yM6K+36LSt5Lmw5ZCO5p+l55yL77yBLywgYGApOwogICAgICAgIGNvbnRlbnQgPSAnPGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PicgKyBjb250ZW50ICsgJzxici8+JyArIGltYWdlcyArICc8YnIvPicgKyB2aWRlb191cmxzICsgJzxici8+PC9ib2R5PjwvaHRtbD4nOwogICAgICAgIGJvZHkuY29udGVudCA9IGNvbnRlbnQ7CiAgICAgICAgcmV0dXJuIGJvZHk7CiAgICB9CgogICAgZnVuY3Rpb24gcmVwbGFjZV9tM3U4KGJvZHksIGhhc192aWRlbykgewogICAgICAgIGxldCBhdHRhY2htZW50cyA9IGJvZHkuYXR0YWNobWVudHM7CiAgICAgICAgbGV0IHZpZHggPSBoYXNfdmlkZW87CiAgICAgICAgaWYgKHZpZHggPCAwKSB7CiAgICAgICAgICAgIHJldHVybiBbYm9keSwgdW5kZWZpbmVkXTsKICAgICAgICB9CiAgICAgICAgaWYgKGJvZHkuc2FsZSA9PT0gbnVsbCB8fCBib2R5LnNhbGUubW9uZXlfdHlwZSA9PSAwKSB7CiAgICAgICAgICAgIHJldHVybiBbYm9keSwgYXR0YWNobWVudHNbdmlkeF1dOwogICAgICAgIH0KICAgICAgICBsZXQgdXJsID0gYXR0YWNobWVudHNbdmlkeF0ucmVtb3RlVXJsOwogICAgICAgIGxldCBtM3U4X3BhdGggPSBnZXRfcmVhbF9tM3U4X3BhdGgodXJsKTsKICAgICAgICBpZiAobTN1OF9wYXRoID09PSB1bmRlZmluZWQpIHsKICAgICAgICAgICAgY29uc29sZS5sb2coJ+inhumikemTvuaOpeiOt+WPluWksei0pSEnKTsKICAgICAgICAgICAgcmV0dXJuIFtib2R5LCBib2R5LmF0dGFjaG1lbnRzW3ZpZHhdXTsKICAgICAgICB9CiAgICAgICAgYm9keS5hdHRhY2htZW50c1t2aWR4XS5yZW1vdGVVcmwgPSBtM3U4X3BhdGg7CiAgICAgICAgcmV0dXJuIFtib2R5LCBib2R5LmF0dGFjaG1lbnRzW3ZpZHhdXTsKICAgIH0KCiAgICBmdW5jdGlvbiByZXBsYWNlX2V4aXN0X2ltZyhib2R5KSB7CiAgICAgICAgbGV0IGNvbnRlbnQgPSBib2R5LmNvbnRlbnQ7CiAgICAgICAgbGV0IGF0dGFjaG1lbnRzID0gYm9keS5hdHRhY2htZW50czsKICAgICAgICBsZXQgYWxsX2ltZyA9IHt9OwogICAgICAgIGxldCBoYXNfdmlkZW8gPSAtMTsKICAgICAgICBmb3IgKHZhciBpID0gMDsgaSA8IGF0dGFjaG1lbnRzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgIHZhciBhdHRhID0gYXR0YWNobWVudHNbaV07CiAgICAgICAgICAgIGlmIChhdHRhLmNhdGVnb3J5ID09PSAnaW1hZ2VzJykgewogICAgICAgICAgICAgICAgYWxsX2ltZ1thdHRhLmlkXSA9IGF0dGEucmVtb3RlVXJsOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGlmIChhdHRhLmNhdGVnb3J5ID09PSAndmlkZW8nKSB7CiAgICAgICAgICAgICAgICBoYXNfdmlkZW8gPSBpOwogICAgICAgICAgICAgICAgcmV0dXJuIFtib2R5LCB1bmRlZmluZWQsIGhhc192aWRlb107CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgbGV0IHJlX2ltZyA9IC88aW1nIHNyYz1cImh0dHBzOlwvXC9bXHdcLlwvXSs/XC9pbWFnZXNcLy4qP1wiIGRhdGEtaWQ9XCIoXGQrKVwiLio/XC8+L2c7CiAgICAgICAgZm9yIChsZXQgZSBvZiBjb250ZW50Lm1hdGNoQWxsKHJlX2ltZykpIHsKICAgICAgICAgICAgbGV0IGlkID0gcGFyc2VJbnQoZVsxXSk7CiAgICAgICAgICAgIGlmIChpZCBpbiBhbGxfaW1nKSB7CiAgICAgICAgICAgICAgICAvLyBsZXQgbnNyYyA9IGFsbF9pbWdbaWRdOwogICAgICAgICAgICAgICAgLy8gbGV0IHNyYyA9IG5ldyBSZWdFeHAoYCg8aW1nIHNyYz1cIilodHRwczpcL1wvW1xcd1wuXC9dKz9cL2ltYWdlc1wvLio/XCgiIGRhdGEtaWQ9XCIke2lkfVwiLio/XC8+KWAsICdnJyk7CiAgICAgICAgICAgICAgICAvLyBjb250ZW50ID0gY29udGVudC5yZXBsYWNlKHNyYywgYCQxJHtuc3JjfSQyYCk7CiAgICAgICAgICAgICAgICBkZWxldGUgYWxsX2ltZ1tpZF07CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgYm9keS5jb250ZW50ID0gY29udGVudDsKICAgICAgICByZXR1cm4gW2JvZHksIGFsbF9pbWcsIGhhc192aWRlb107CiAgICB9CgogICAgZnVuY3Rpb24gbW9kaWZ5X2RhdGEoZGF0YSkgewogICAgICAgIGxldCBib2R5ID0gSlNPTi5wYXJzZShkZWNvZGUoZGF0YSkpOwogICAgICAgIGlmIChib2R5Lm5vZGUudmlwTGltaXQgIT0gMCkgewogICAgICAgICAgICBib2R5ID0gcmVtb3ZlX3ZpcChib2R5KTsKICAgICAgICAgICAgcmV0dXJuIGplbmNvZGUoYm9keSk7CiAgICAgICAgfQogICAgICAgIGxldCBbbmJvZHksIHJlc3RfaW1nLCBoYXNfdmlkZW9dID0gcmVwbGFjZV9leGlzdF9pbWcoYm9keSk7CiAgICAgICAgYm9keSA9IG5ib2R5OwogICAgICAgIC8vIOW3sui0reS5sOeahOW4luWtkAogICAgICAgIGlmIChib2R5LmNvbnRlbnQuaW5jbHVkZXMoYFsvc2VsbF1gKSkgewogICAgICAgICAgICByZXR1cm4gamVuY29kZShib2R5KTsKICAgICAgICB9CiAgICAgICAgaWYgKCdzYWxlJyBpbiBib2R5ICYmIGJvZHkuc2FsZSAhPT0gbnVsbCkgewogICAgICAgICAgICBib2R5LnNhbGUuaXNfYnV5ID0gdHJ1ZTsKICAgICAgICAgICAgYm9keS5zYWxlLmJ1eV9pbmRleCA9IHBhcnNlSW50KE1hdGgucmFuZG9tKCkgKiAoNTAwMCAtIDEwMDAgKyAxKSArIDEwMDAsIDEwKTsKICAgICAgICB9CiAgICAgICAgaWYgKGhhc192aWRlbyA+PSAwKSB7CiAgICAgICAgICAgIGxldCBbbmJvZHksIHZdID0gcmVwbGFjZV9tM3U4KGJvZHksIGhhc192aWRlbyk7CiAgICAgICAgICAgIHJldHVybiBqZW5jb2RlK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vXC9hcGlcL3RvcGljXC9cZCsvOwogICAgY29uc3QgcmVfdXNlciA9IC9cL2FwaVwvdXNlclwvaW5mb1wvXGQrLzsKCiAgICBYTUxIdHRwUmVxdWVzdC5wcm90b3R5cGUub3BlbiA9IGZ1bmN0aW9uIChfLCB1cmwpIHsKICAgICAgICAvLyDmi6bmiKp0b3BpYwogICAgICAgIGlmIChyZV90b3BpYy50ZXN0KHVybCkpIHsKICAgICAgICAgICAgY29uc3QgeGhyID0gdGhpczsKICAgICAgICAgICAgY29uc3QgZ2V0dGVyID0gT2JqZWN0LmdldE93blByb3BlcnR5RGVzY3JpcHRvcigKICAgICAgICAgICAgICAgIFhNTEh0dHBSZXF1ZXN0LnByb3RvdHlwZSwKICAgICAgICAgICAgICAgICJyZXNwb25zZSIKICAgICAgICAgICAgKS5nZXQ7CiAgICAgICAgICAgIE9iamVjdC5kZWZpbmVQcm9wZXJ0eSh4aHIsICJyZXNwb25zZVRleHQiLCB7CiAgICAgICAgICAgICAgICBnZXQ6ICgpID0+IHsKICAgICAgICAgICAgICAgICAgICBsZXQgcmVzdWx0ID0gZ2V0dGVyLmNhbGwoeGhyKTsKICAgICAgICAgICAgICAgICAgICB0cnkgewogICAgICAgICAgICAgICAgICAgICAgICBsZXQgcmVzID0gSlNPTi5wYXJzZShyZXN1bHQsIGB1dGYtOGApOwogICAgICAgICAgICAgICAgICAgICAgICAvLyDov5nph4zkv67mlLlkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIHJlcy5kYXRhID0gbW9kaWZ5X2RhdGEocmVzLmRhdGEpCiAgICAgICAgICAgICAgICAgICAgICAgIHJldHVybiBKU09OLnN0cmluZ2lmeShyZXMsIGB1dGYtOGApOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ+WPkeeUn+W8guW4uCEg6Kej5p6Q5aSx6LSlIScpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICB9KTsKICAgICAgICB9IGVsc2UgaWYgKHJlX3VzZXIudGVzdCh1cmwpKSB7CiAgICAgICAgICAgIGNvbnN0IHhociA9IHRoaXM7CiAgICAgICAgICAgIGNvbnN0IGdldHRlciA9IE9iamVjdC5nZXRPd25Qcm9wZXJ0eURlc2NyaXB0b3IoCiAgICAgICAgICAgICAgICBYTUxIdHRwUmVxdWVzdC5wcm90b3R5cGUsCiAgICAgICAgICAgICAgICAicmVzcG9uc2UiCiAgICAgICAgICAgICkuZ2V0OwogICAgICAgICAgICBPYmplY3QuZGVmaW5lUHJvcGVydHkoeGhyLCAicmVzcG9uc2VUZXh0IiwgewogICAgICAgICAgICAgICAgZ2V0OiAoKSA9PiB7CiAgICAgICAgICAgICAgICAgICAgbGV0IHJlc3VsdCA9IGdldHRlci5jYWxsKHhocik7CiAgICAgICAgICAgICAgICAgICAgdHJ5IHsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IHJlcyA9IEpTT04ucGFyc2UocmVzdWx0LCBgdXRmLThgKTsKICAgICAgICAgICAgICAgICAgICAgICAgbGV0IGZ1cmwgPSB4aHIucmVzcG9uc2VVUkw7CiAgICAgICAgICAgICAgICAgICAgICAgIGxldCByID0gZnVybC5tYXRjaCgvXFcqKFx3KylcLmNvbVwvYXBpXC91c2VyXC9pbmZvXC8oXGQrKS8pOwogICAgICAgICAgICAgICAgICAgICAgICAvLyDov5nph4zkv67mlLlkYXRhCiAgICAgICAgICAgICAgICAgICAgICAgIGxldCBkYXRhID0gbW9kaWZ5X3VzZXIocmVzLCByWzFdLCByWzJdKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIEpTT04uc3RyaW5naWZ5KGRhdGEsIGB1dGYtOGApOwogICAgICAgICAgICAgICAgICAgIH0gY2F0Y2ggKGUpIHsKICAgICAgICAgICAgICAgICAgICAgICAgY29uc29sZS5sb2coJ+WPkeeUn+W8guW4uCEg6Kej5p6Q5aSx6LSlIScpOwogICAgICAgICAgICAgICAgICAgICAgICBjb25zb2xlLmxvZyhlKTsKICAgICAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHJlc3VsdDsKICAgICAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgICAgICB9LAogICAgICAgICAgICB9KTsKICAgICAgICB9CiAgICAgICAgb3JpZ2luT3Blbi5hcHBseSh0aGlzLCBhcmd1bWVudHMpOwogICAgfTsKCiAgICBsZXQgY2xpY2tlZF9mbGFnID0gZmFsc2U7CiAgICAKICAgIGRvY3VtZW50LmFkZEV2ZW50TGlzdGVuZXIoIkRPTU5vZGVJbnNlcnRlZCIsIGZ1bmN0aW9uIChldmVudCkgewogICAgICAgIGlmICghY2xpY2tlZF9mbGFnKSB7CiAgICAgICAgICAgIGZvciAoY29uc3QgZWxlbWVudCBvZiBkb2N1bWVudC5nZXRFbGVtZW50c0J5Q2xhc3NOYW1lKCdlbC1tZXNzYWdlLWJveCcpKSB7CiAgICAgICAgICAgICAgICBpZiAoZWxlbWVudC5pbm5lclRleHQuaW5kZXhPZign5Luk54mM5bey6L+H5pyfJykgPiAtMSkgewogICAgICAgICAgICAgICAgICAgIGNsaWNrZWRfZmxhZyA9IHRydWU7CiAgICAgICAgICAgICAgICAgICAgbGV0IGUgPSBlbGVtZW50LnF1ZXJ5U2VsZWN0b3IoImRpdi5lbC1tZXNzYWdlLWJveF9faGVhZGVyID4gYnV0dG9uIik7CiAgICAgICAgICAgICAgICAgICAgc2V0VGltZW91dCgoZSkgPT4geyBlLmNsaWNrKCk7IH0sIDEwMCwgZSk7CiAgICAgICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgICAgICB9CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICAgICAgaWYgKGV2ZW50LnJlbGF0ZWROb2RlLmdldEF0dHJpYnV0ZSgnaWQnKSA9PT0gJ3RpZGlvLWNoYXQnKSB7CiAgICAgICAgICAgIHZhciBlbGVzID0gZG9jdW1lbnQuZ2V0RWxlbWVudHNCeVRhZ05hbWUoJyonKTsKICAgICAgICAgICAgZm9yICh2YXIgaSA9IDA7IGkgPCBlbGVzLmxlbmd0aDsgaSsrKSB7CiAgICAgICAgICAgICAgICBlbGVzW2ldLnN0eWxlLnVzZXJTZWxlY3QgPSAndGV4dCc7CiAgICAgICAgICAgIH0KICAgICAgICB9CiAgICB9LCBmYWxzZSk7Cgp9KSgpOw==
Add Comment
Please, Sign In to add comment