Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 海阔视界规则分享,当前分享的是:网页插件¥js_url¥global_haijiao-vip:海角社区解锁收费视频,VIP,去广告@base64://Ci8vID09VXNlclNjcmlwdD09Ci8vIEBuYW1lICAgICAgICAgICBoYWlqaWFvLXZpcDog5rW36KeS56S+5Yy6IOino+mUgeaUtui0ueinhumikSxWSVAs5Y675bm/5ZGKCi8vIEBuYW1lc3BhY2UgICAgICBodHRwczovL2dpdGh1Yi5jb20vc2V4NDA5Ni9oYWlqaWFvX3ZpcAovLyBAdmVyc2lvbiAgICAgICAgMS4xLjIKLy8gQGF1dGhvciAgICAgICAgIGZvcmdldG1lOAovLyBAZGVzY3JpcHRpb24gICAg6Kej6ZSBIOa1t+inkuekvuWMuihoYWlqaWFvLmNvbSkg5pS26LS56KeG6aKRLFZJUCzlubbljrvpmaTnvZHnq5nlub/lkYosIFRH6aKR6YGTOkBzdmlwX25hdi7mnKzmj5Lku7blrozlhajlhY3otLks6K+35rOo5oSP55SE5YirLOmBv+WFjeS4iuW9k+WPl+mqly4KLy8gQGhvbWVwYWdlICAgICAgIGh0dHBzOi8vZ2l0aHViLmNvbS9zZXg0MDk2L2hhaWppYW9fdmlwI3JlYWRtZQovLyBAc3VwcG9ydFVSTCAgICAgaHR0cHM6Ly9naXRodWIuY29tL3NleDQwOTYvaGFpamlhb192aXAvaXNzdWUKLy8gQHJ1bi1hdCAgICAgICAgIGRvY3VtZW50LWlkbGUKLy8gQG1hdGNoICAgICAgICAgIGh0dHBzOi8vd3d3LmhqY3gub3JnLyoKLy8gQG1hdGNoICAgICAgICAgIGh0dHBzOi8vaGpjeC5vcmcvKgovLyBAbWF0Y2ggICAgICAgICAgaHR0cHM6Ly93d3cuaGpjeC5jYy8qCi8vIEBtYXRjaCAgICAgICAgICBodHRwczovL2hqY3guY2MvKgovLyBAbWF0Y2ggICAgICAgICAgaHR0cHM6Ly93d3cuaGFpamlhby5jb20vKgovLyBAbWF0Y2ggICAgICAg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MoInVzZXJJZCIpKSB7CiAgICAgICAgICBjb25zb2xlLmxvZygi5p+l55yL6KKrYmFu55qE55So5oi35L+h5oGvIiwgcmVxdWVzdC51cmwpOwogICAgICAgICAgdmFyIGhvc3QgPSBQbHVnaW5TdG9yZS5nZXQoImhvc3QiLCAiIik7CiAgICAgICAgICByZXF1ZXN0LmJhc2VVUkwgPSBob3N0OwogICAgICAgICAgcmVxdWVzdC5jcm9zc0RvbWFpbiA9IHRydWU7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiByZXF1ZXN0OwogICAgfQoKICAgIC8qKgogICAgICog6Kej6ZSB5pCc57Si5Yqf6IO9CiAgICAgKiBAcGFyYW0gcmVxdWVzdAogICAgICovCiAgICBhc3luYyByZXF1ZXN0U2VhcmNoSW50ZXJjZXB0b3IocmVxdWVzdCkgewogICAgICBpZiAoUGx1Z2luU3RvcmUuZ2V0KCJ1bmxvY2tTZWFyY2giLCB0cnVlKSA9PT0gdHJ1ZSAmJiBQbHVnaW5TdG9yZS5nZXQoImhvc3QiLCAiIikubGVuZ3RoID4gMCkgewogICAgICAgIGlmICgvXC9hcGlcL3VzZXJcL3NlYXJjaC9nLnRlc3QocmVxdWVzdC51cmwpKSB7CiAgICAgICAgICBjb25zb2xlLmxvZygi5pCc57SiIiwgcmVxdWVzdC51cmwpOwogICAgICAgICAgdmFyIGhvc3QgPSBQbHVnaW5TdG9yZS5nZXQoImhvc3QiLCAiIik7CiAgICAgICAgICByZXF1ZXN0LmJhc2VVUkwgPSBob3N0OwogICAgICAgICAgcmVxdWVzdC5jcm9zc0RvbWFpbiA9IHRydWU7CiAgICAgICAgfQogICAgICB9CiAgICAgIHJldHVybiByZXF1ZXN0OwogICAgfQoKICAgIC8qKgogICAgICog5a+56L+U5Zue5pWw5o2u6L+b6KGM6Kej56CBCiAgICAgKiBAcGFyYW0gcmVzcG9uc2UKICAgICAqLwogICAgYXN5bmMgcmVzcG9uc2VEZWNvZGVJbnRlcmNlcHRvcihyZXN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gICAgICAgbW9iaWxlOiBmYWxzZSwKICAgICAgICAgIG9yaWdpbl9yZXNwb25zZTogb3JpZ2luX3Jlc3BvbnNlCiAgICAgICAgfTsKICAgICAgfQogICAgICByZXR1cm4gcmVzcG9uc2U7CiAgICB9CgogICAgLyoqCiAgICAgKiDlr7lyZXBvbnNl6YeN5paw57yW56CBCiAgICAgKiBAcGFyYW0gcmVzcG9uc2UKICAgICAqIEByZXR1cm5zCiAgICAgKi8KICAgIGFzeW5jIHJlc3BvbnNlRW5jb2RlSW50ZXJjZXB0b3IocmVzcG9uc2UpIHsKICAgICAgaWYgKHJlc3BvbnNlLm1vYmlsZSA9PT0gdHJ1ZSkgewogICAgICAgIHZhciBkZWMgPSByZXNwb25zZS5pdGVtOwogICAgICAgIGlmIChyZXNwb25zZS5vcmlnaW5fcmVzcG9uc2UuaXNFbmNyeXB0ZWQgPT09IHRydWUpIHsKICAgICAgICAgIGNvbnN0IEJhc2U2NCA9IGdldE1vZHVsZSgiZTc2MiIpLmE7CiAgICAgICAgICBkZWMgPSBCYXNlNjQuZW5jb2RlKEJhc2U2NC5lbmNvZGUoQmFzZTY0LmVuY29kZShKU09OLnN0cmluZ2lmeShyZXNwb25zZS5pdGVtKSkpKTsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIHsKICAgICAgICAgIGRhdGE6IHsKICAgICAgICAgICAgLi4ucmVzcG9uc2Uub3JpZ2luX3Jlc3BvbnNlLAogICAgICAgICAgICBkYXRhOiBkZWMKICAgICAgICAgIH0KICAgICAgICB9OwogICAgICB9IGVsc2UgewogICAgICAgIHJldHVybiB7CiAgICAgICAgICAuLi5yZXNwb25zZS5vcmlnaW5fcmVzcG9uc2UsCiAgICAgICAgICBkYXRhOiByZXNwb25zZS5pdGVtCiAgICAgICAgfTsKICAgICAgfQogICAgfQogICAgYXN5bmMgcmVzcG9uc2VJbnRlcmNlcHRvcihyZXNwb25zZSkgewogICAgICBjb25zdCB1cmwgPSByZXNwb25zZS51cmwudG9Mb3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gPiAwKSB7CiAgICAgICAgZGF0YS5ub2RlLnZpcExpbWl0ID0gMDsKICAgICAgfQogICAgICB2YXIgY29udGVudCA9IGRhdGEuY29udGVudDsKICAgICAgaWYgKGNvbnRlbnQgJiYgIWNvbnRlbnQuc3RhcnRzV2l0aCgiPGh0bWw+PGhlYWQ+PC9oZWFkPjxib2R5PiIpKSB7CiAgICAgICAgLy8g5Yig6Zmk5o6JW13moIfnrb4KICAgICAgICBjb250ZW50ID0gY29udGVudC5yZXBsYWNlKC9cW+inhumikVxdL2csICIiKTsKICAgICAgICBjb250ZW50ID0gY29udGVudC5yZXBsYWNlKC9cW+WbvueJh1xdL2csICIiKTsKICAgICAgICBjb250ZW50ID0gY29udGVudC5yZXBsYWNlKC/mraTlpITlhoXlrrnllK7ku7dcZCvph5HluIEuKuivt+i0reS5sOWQjuafpeeciy4vZywgIiIpOwogICAgICAgIGNvbnRlbnQgPSBjb250ZW50LnJlcGxhY2UoL1xbc2VsbC4qXC9zZWxsXS9nLCAiIik7CiAgICAgICAgZGF0YS5hdHRhY2htZW50cz8uZm9yRWFjaChhdHRhY2htZW50ID0+IHsKICAgICAgICAgIHZhciBoYXNJbWFnZSwKICAgICAgICAgICAgaGFzVmlkZW8gPSBmYWxzZTsKICAgICAgICAgIC8vIOWkhOeQhuWbvueJhwogICAgICAgICAgaWYgKGF0dGFjaG1lbnQuY2F0ZWdvcnkgPT09ICJpbWFnZXMiICYmIGF0dGFjaG1lbnQucmVtb3RlVXJsKSB7CiAgICAgICAgICAgIGNvbnRlbnQgPSBjb250ZW50ICs9IGA8cD48aW1nIHNyYz0iJHthdHRhY2htZW50LnJlbW90ZVVybH0iIGRhdGEtaWQ9IiR7YXR0YWNobWVudC5pZH0iLz5gOwogICAgICAgICAgICBoYXNJbWFnZSA9IHRydWU7CiAgICAgICAgICB9CiAgICAgICAgICBpZiAoaGFzSW1hZ2UgPT09IHRydWUpIHsKICAgICAgICAgICAgY29udGVudCA9IGA8cD4ke2NvbnRlbn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J0eS5jYWxsKGRhdGEsICJhdHRhY2htZW50cyIpICYmIGRhdGEuYXR0YWNobWVudHMubGVuZ3RoID4gMCkgewogICAgICAgICAgZGF0YS5hdHRhY2htZW50cy5mb3JFYWNoKGF0dGFjaG1lbnQgPT4gewogICAgICAgICAgICBpZiAoYXR0YWNobWVudC5jYXRlZ29yeSA9PT0gInZpZGVvIikgewogICAgICAgICAgICAgIC8vIOWIm+W7uuS4gOS4quaWsHRhZ+WKoOWFpeWIsGJvZHnkuK0KICAgICAgICAgICAgICBjb25zdCB2aWRlbyA9IGRvYy5jcmVhdGVFbGVtZW50KCJ2aWRlbyIpOwogICAgICAgICAgICAgIHZpZGVvLnNyYyA9IGF0dGFjaG1lbnQucmVtb3RlVXJsOwogICAgICAgICAgICAgIHZpZGVvLnNldEF0dHJpYnV0ZSgiZGF0YS1pZCIsIGF0dGFjaG1lbnQuaWQpOwogICAgICAgICAgICAgIGRvYy5ib2R5LmFwcGVuZENoaWxkKHZpZGVvKTsKICAgICAgICAgICAgfQogICAgICAgICAgfSk7CiAgICAgICAgfQogICAgICAgIGNvbnN0IHNlcmlhbGl6ZXIgPSBuZXcgWE1MU2VyaWFsaXplcigpOwogICAgICAgIGNvbnN0IHNlcmlhbGl6ZWRIVE1MID0gc2VyaWFsaXplci5zZXJpYWxpemVUb1N0cmluZyhkb2MpOwogICAgICAgIGNvbnRlbnQgPSBzZXJpYWxpemVkSFRNTDsKICAgICAgfQogICAgICBkYXRhLmNvbnRlbnQgPSBjb250ZW50OwogICAgICByZXR1cm4gZGF0YTsKICAgIH0KCiAgICAvKioKICAgICAqIOWOu+W5v+WRigogICAgICogQHBhcmFtIGRhdGEKICAgICAqLwogICAgYXN5bmMgZml4QWRzKGRhdGEpIHsKICAgICAgcmV0dXJuIG51bGw7CiAgICB9CiAgICBhc3luYyBmaXhUb3BzKGRhdGEpIHsKICAgICAgcmV0dXJuIFtdOwogICAgfQogIH0KCiAgZnVuY3Rpb24gYWRkU3R5bGUoKSB7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