Syleront / VK-Raspisator

// ==UserScript==
// @name VK-Raspisator
// @version 1.1.0
// @author Syleront
// @match *://*.vk.com/*
// @connect vk.com
// @run-at document-start
// @updateURL https://openuserjs.org/meta/Syleront/VK-Raspisator.meta.js
// @downloadURL https://openuserjs.org/src/scripts/Syleront/VK-Raspisator.user.js
// @copyright 2019, Syleront
// @license MIT
// ==/UserScript==

// This is a production build, source available at https://github.com/syleront/vk-raspisator

(function(){var d=Math.floor;function a(a){let b=parseInt(a,10),c=d(b/3600),e=d((b-3600*c)/60),f=b-3600*c-60*e;return 10>c&&(c="0"+c),10>e&&(e="0"+e),10>f&&(f="0"+f),0<c?`${c}:${e}:${f}`:`${e}:${f}`}function b(a){try{return a instanceof HTMLElement}catch(b){return"object"==typeof a&&1===a.nodeType&&"object"==typeof a.style&&"object"==typeof a.ownerDocument}}function c(){const a=[];this.emit=(b,c)=>{a.forEach(a=>{a.name===b&&a._cb(c)})},this.on=(b,c)=>{a.push({name:b,_cb:c})}}class e{static load(){const a=document.createElement("style");a.type="text/css",a.innerHTML=".rs-box {\r\n  text-align: center;\r\n  display: flex;\r\n  flex-direction: column;\r\n  align-items: center;\r\n  padding: 0 10px;\r\n}\r\n\r\n.rs-box .header {\r\n  text-align: start;\r\n  width: 100%;\r\n}\r\n\r\n.rs-box .input-container {\r\n  margin-top: 8px;\r\n  width: 100%;\r\n}\r\n\r\n.rs-box .input-container .input {\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n  resize: none;\r\n  height: 100px;\r\n}\r\n\r\n.rs-box .attachment-states {\r\n  width: 100%;\r\n}\r\n\r\n.rs-box .attachment-states .state {\r\n  text-overflow: ellipsis;\r\n  overflow: hidden;\r\n  white-space: nowrap;\r\n}\r\n\r\n.rs-box .attachment-container {\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n}\r\n\r\n.rs-box .attachment-container .photos,\r\n.rs-box .attachment-container .videos {\r\n  width: 100%;\r\n  margin-top: 5px;\r\n  display: flex;\r\n  flex-wrap: wrap;\r\n  justify-content: center;\r\n}\r\n\r\n.rs-box .attachment-container .photos .photo,\r\n.rs-box .attachment-container .videos .video {\r\n  width: 100px;\r\n  height: 70px;\r\n  margin: 5px;\r\n  position: relative;\r\n  background-size: cover;\r\n  cursor: pointer;\r\n}\r\n\r\n.rs-box .attachment-container .videos .video .rs_vl {\r\n  margin: 2px;\r\n}\r\n\r\n.rs-box .attachment-container .audios {\r\n  margin-top: 5px;\r\n}\r\n\r\n.rs-box .attachment-container .audios .audio {\r\n  display: flex;\r\n  align-items: center;\r\n}\r\n\r\n.rs-box .attachment-container .audios .audio .rs_al {\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n}\r\n\r\n.rs-box .attachment-container .docs {\r\n  text-align: initial;\r\n  margin-top: 5px;\r\n}\r\n\r\n.rs-box .attachment-container .docs .doc {\r\n  display: flex;\r\n  align-items: center;\r\n}\r\n\r\n.rs-box .attachment-container .docs .rs_dl {\r\n  padding: 5px;\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n}\r\n\r\n.rs-box .settings-container {\r\n  display: flex;\r\n  flex-flow: column;\r\n  text-align: initial;\r\n  border-top: 1px inset;\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n}\r\n\r\n.rs-box .settings-container .header {\r\n  padding: 2px;\r\n}\r\n\r\n.rs-box .settings-container .rs_sl {\r\n  display: flex;\r\n  padding: 5px;\r\n  margin-left: 5px;\r\n}\r\n\r\n.rs-box .settings-container .rs_sl .rs-select {\r\n  margin-left: 10px;\r\n\r\n  /* vanilla dark vk support */\r\n  background: var(--color3);\r\n  border-color: var(--color7);\r\n  color: var(--color6)\r\n}\r\n\r\n.rs-box .attach-controls {\r\n  display: flex;\r\n  justify-content: flex-end;\r\n}\r\n\r\n._close_btn.rs_cl {\r\n  position: inherit;\r\n  margin-left: 10px;\r\n}\r\n\r\n.worker-body .log {\r\n  width: -webkit-fill-available;\r\n  width: -moz-available;\r\n  border: 1px solid;\r\n  height: 200px;\r\n  padding: 10px;\r\n  overflow-y: auto;\r\n  overflow-x: hidden;\r\n}\r\n\r\n.worker-body .progress-container {\r\n  margin-top: 15px;\r\n  display: flex;\r\n  flex-direction: column;\r\n}\r\n\r\n.worker-body .progress-container>.wr-pb {\r\n  margin-top: 7px;\r\n  align-self: center;\r\n  width: 80%;\r\n}\r\n\r\n.worker-body .progress-container .percents-bar {\r\n  align-self: center;\r\n}\r\n\r\n/* .rs-box .attach-controls input {\r\n  display: none;\r\n} */\r\n\r\n/* .rs-box .photo-attach {\r\n  background: url(\"data:image/svg+xml;charset=utf-8,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2224%22%20height%3D%2224%22%20viewBox%3D%220%200%2024%2024%22%3E%3Cg%20fill%3D%22none%22%20stroke%3D%22%23828A99%22%20stroke-width%3D%221.7%22%3E%3Cpath%20d%3D%22M14.134%203.65c.853%200%201.46.278%201.988.899.017.019.494.61.66.815.228.281.674.536.945.536h.41C20.556%205.9%2022%207.463%2022%209.95v5.85c0%202.241-2%204.2-4.273%204.2H6.273c-2.267%200-4.223-1.953-4.223-4.2V9.95c0-2.496%201.4-4.05%203.814-4.05h.409c.271%200%20.717-.255.945-.536.166-.204.643-.796.66-.815.528-.621%201.135-.899%201.988-.899h4.268z%22%2F%3E%3Ccircle%20cx%3D%2212%22%20cy%3D%2212%22%20r%3D%223.85%22%2F%3E%3C%2Fg%3E%3C%2Fsvg%3E\") 50% no-repeat;\r\n  width: 24px;\r\n  height: 24px;\r\n  padding: 6px 7px 6px 5px;\r\n  opacity: 0.7;\r\n  cursor: pointer;\r\n  display: block;\r\n}\r\n\r\n.rs-box .photo-attach:hover {\r\n  opacity: 1;\r\n} */",document.head.appendChild(a)}}class f{constructor(){this.events=[],this.init()}emit(a,b){"object"==typeof b&&b.dataset&&!b.dataset.rsPassed&&(b.dataset.rsPassed=!0,this.events.forEach(c=>{c.name===a&&c._cb(b)}))}on(a,b){this.events.push({name:a,_cb:b})}init(){new MutationObserver(a=>{a.forEach(a=>{const b=Array.from(a.addedNodes),c=this;b.forEach(function a(b){const{classList:d,dataset:e}=b;if("wrap2"===b.id||"profile_wall"===b.id||"group_wall"===b.id){const c=b.querySelectorAll("*");Array.from(c).forEach(a)}else e&&e.postId&&d&&d.contains("post")&&c.emit("WallPost",b)})})}).observe(document,{childList:!0,subtree:!0})}}class g{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"rs-box\">\r\n  <div class=\"header\">\r\n    <span>\u0421\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435 \u0434\u043B\u044F \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0438</span>\r\n  </div>\r\n  <div class=\"input-container\">\r\n    <textarea class=\"input\"></textarea>\r\n    <div class=\"media_selector clear_fix\">\r\n      <a class=\"ms_item ms_item_photo _type_photo\" tabindex=\"0\" data-title=\"\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F\" aria-label=\"\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F\" role=\"link\">\r\n        <span class=\"blind_label\">\u0424\u043E\u0442\u043E\u0433\u0440\u0430\u0444\u0438\u044F</span>\r\n      </a>\r\n      <a class=\"ms_item ms_item_video _type_video\" tabindex=\"0\" data-title=\"\u0412\u0438\u0434\u0435\u043E\u0437\u0430\u043F\u0438\u0441\u044C\" aria-label=\"\u0412\u0438\u0434\u0435\u043E\u0437\u0430\u043F\u0438\u0441\u044C\" role=\"link\">\r\n        <span class=\"blind_label\">\u0412\u0438\u0434\u0435\u043E\u0437\u0430\u043F\u0438\u0441\u044C</span>\r\n      </a>\r\n      <a class=\"ms_item ms_item_audio _type_audio\" tabindex=\"0\" data-title=\"\u0410\u0443\u0434\u0438\u043E\u0437\u0430\u043F\u0438\u0441\u044C\" aria-label=\"\u0410\u0443\u0434\u0438\u043E\u0437\u0430\u043F\u0438\u0441\u044C\" role=\"link\">\r\n        <span class=\"blind_label\">\u0410\u0443\u0434\u0438\u043E\u0437\u0430\u043F\u0438\u0441\u044C</span>\r\n      </a>\r\n      <a class=\"ms_item ms_item_doc _type_doc\" tabindex=\"0\" data-title=\"\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\" aria-label=\"\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442\" role=\"link\">\r\n        <span class=\"blind_label\">\u0414\u043E\u043A\u0443\u043C\u0435\u043D\u0442</span>\r\n      </a>\r\n    </div>\r\n  </div>\r\n  <div class=\"attachment-states\"></div>\r\n  <div class=\"attachment-container\">\r\n    <div class=\"photos\"></div>\r\n    <div class=\"videos\"></div>\r\n    <div class=\"audios\"></div>\r\n    <div class=\"docs\"></div>\r\n  </div>\r\n  <div class=\"settings-container\">\r\n    <div class=\"header\">\u041D\u0430\u0441\u0442\u0440\u043E\u0439\u043A\u0438</div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox\" data-param-type=\"sendBy\" data-send-type=\"like\" role=\"checkbox\" aria-checked=\"false\" tabindex=\"0\">\r\n        \u041F\u043E \u043B\u0430\u0439\u043A\u0430\u043C\r\n      </div>\r\n    </div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox on\" data-param-type=\"sendBy\" data-send-type=\"repost\" role=\"checkbox\" aria-checked=\"true\" tabindex=\"0\">\r\n        \u041F\u043E \u0440\u0435\u043F\u043E\u0441\u0442\u0430\u043C\r\n      </div>\r\n    </div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox\" data-param-type=\"needSubscribe\" role=\"checkbox\" aria-checked=\"false\" tabindex=\"0\">\r\n        \u0414\u043E\u043B\u0436\u0435\u043D \u0431\u044B\u0442\u044C \u043F\u043E\u0434\u043F\u0438\u0441\u0430\u043D\r\n      </div>\r\n    </div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox on\" data-param-type=\"countRecievedUsers\" role=\"checkbox\" aria-checked=\"true\" tabindex=\"0\">\r\n        \u0423\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u043F\u043E\u043B\u0443\u0447\u0438\u0432\u0448\u0438\u0445\r\n      </div>\r\n      <span class=\"hint_icon\" onmouseover=\"showTooltip(this, {text: '\u041F\u0440\u0438 \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0435, \u0441\u043A\u0440\u0438\u043F\u0442 \u0441\u043E\u0445\u0440\u0430\u043D\u044F\u0435\u0442 \u0442\u0435\u0445, \u043A\u0442\u043E \u0443\u0436\u0435 \u043F\u043E\u043B\u0443\u0447\u0438\u043B \u0440\u043E\u0441\u043F\u0438\u0441\u044C. \u0415\u0441\u043B\u0438 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \u0432\u043A\u043B\u044E\u0447\u0435\u043D - \u043E\u043D \u043F\u0440\u043E\u043F\u0443\u0441\u043A\u0430\u0435\u0442 \u0442\u0435\u0445, \u043A\u0442\u043E \u0443\u0436\u0435 \u043F\u043E\u043B\u0443\u0447\u0438\u043B \u0440\u043E\u0441\u043F\u0438\u0441\u044C \u0441 \u0434\u0430\u043D\u043D\u043E\u0439 \u0437\u0430\u043F\u0438\u0441\u0438. \u0415\u0441\u043B\u0438 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \u0432\u044B\u043A\u043B\u044E\u0447\u0435\u043D, \u0442\u043E \u043F\u0440\u0438 \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0435 \u043F\u0440\u043E\u0448\u043B\u044B\u0439 \u0441\u043F\u0438\u0441\u043E\u043A \u043F\u043E\u043B\u0443\u0447\u0438\u0432\u0448\u0438\u0445 (\u0435\u0441\u043B\u0438 \u043E\u043D \u0431\u044B\u043B) \u0431\u0443\u0434\u0435\u0442 \u0443\u0434\u0430\u043B\u0435\u043D, \u0438 \u0432\u043C\u0435\u0441\u0442\u043E \u043D\u0435\u0433\u043E \u0431\u0443\u0434\u0435\u0442 \u0441\u043E\u0437\u0434\u0430\u043D \u043D\u043E\u0432\u044B\u0439. \u042D\u0442\u043E \u043F\u043E\u043B\u0435\u0437\u043D\u043E, \u0435\u0441\u043B\u0438 \u043D\u0435\u043A\u043E\u0442\u043E\u0440\u044B\u0435 \u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u0435\u043B\u0438 \u0437\u0430\u0431\u044B\u043B\u0438 \u043E\u0442\u043A\u0440\u044B\u0442\u044C \u0441\u0442\u0435\u043D\u0443, \u0438 \u043D\u0435 \u043F\u043E\u043B\u0443\u0447\u0438\u043B\u0438 \u0440\u043E\u0441\u043F\u0438\u0441\u044C, \u043B\u0438\u0431\u043E \u0432 \u043F\u0440\u043E\u0448\u043B\u044B\u0439 \u0440\u0430\u0437 \u0431\u044B\u043B \u0434\u043E\u0441\u0442\u0438\u0433\u043D\u0443\u0442 \u043B\u0438\u043C\u0438\u0442 \u043F\u043E \u043E\u0441\u0442\u0430\u0432\u043B\u0435\u043D\u043D\u044B\u043C \u0437\u0430\u043F\u0438\u0441\u044F\u043C.', dir: 'auto', shift: [22, 10], slide: 15, className: 'settings_tt'})\">\r\n      </span>\r\n    </div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox on\" data-param-type=\"needWebApi\" role=\"checkbox\" aria-checked=\"true\" tabindex=\"0\">\r\n        \u0418\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C Web Api\r\n      </div>\r\n      <span class=\"hint_icon\" onmouseover=\"showTooltip(this, {text: '\u041F\u0440\u0438 \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u0438 \u043F\u043E\u0441\u0442\u0430, \u0432\u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0435 \u043E\u0441\u0442\u0430\u0432\u043B\u044F\u0435\u0442 \u043F\u043E\u043C\u0435\u0442\u043A\u0443, \u0441 \u0447\u0435\u0433\u043E \u0431\u044B\u043B \u0441\u0434\u0435\u043B\u0430\u043D \u044D\u0442\u043E\u0442 \u043F\u043E\u0441\u0442 (android, ios, \u0438 \u0442\u0434.), \u0432 \u0434\u0430\u043D\u043D\u043E\u043C \u0441\u043B\u0443\u0447\u0430\u0435 - \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0435 API.Console. \u0415\u0441\u043B\u0438 \u044D\u0442\u043E\u0442 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \u0432\u043A\u043B\u044E\u0447\u0435\u043D, \u0442\u043E \u0440\u0430\u0441\u043F\u0438\u0441\u0430\u0442\u043E\u0440 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C Web Api \u0434\u043B\u044F \u0441\u043E\u0437\u0434\u0430\u043D\u0438\u044F \u043F\u043E\u0441\u0442\u0430, \u0438 \u043D\u0438\u043A\u0430\u043A\u0438\u0445 \u043F\u043E\u043C\u0435\u0442\u043E\u043A \u043D\u0435 \u0431\u0443\u0434\u0435\u0442. \u041E\u0434\u043D\u0430\u043A\u043E, \u0442\u0430\u043A \u043A\u0430\u043A \u044D\u0442\u043E \u0432\u043D\u0443\u0442\u0440\u0435\u043D\u043D\u0438\u0439 \u0441\u043F\u043E\u0441\u043E\u0431 \u0441\u0430\u043C\u043E\u0433\u043E \u0432\u043A, \u0442\u043E \u0441\u0442\u0430\u0431\u0438\u043B\u044C\u043D\u0430\u044F \u0440\u0430\u0431\u043E\u0442\u0430 \u043D\u0435 \u0433\u0430\u0440\u0430\u043D\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044F. \u0420\u0435\u043A\u043E\u043C\u0435\u043D\u0434\u0443\u0435\u0442\u0441\u044F \u043E\u0441\u0442\u0430\u0432\u0438\u0442\u044C, \u0435\u0441\u043B\u0438 \u043F\u0440\u043E\u044F\u0432\u043B\u044F\u044E\u0442\u0441\u044F \u043A\u0430\u043A\u0438\u0435-\u0442\u043E \u043F\u0440\u043E\u0431\u043B\u0435\u043C\u044B, \u0442\u043E \u043E\u0442\u043A\u043B\u044E\u0447\u0438\u0442\u0435.', dir: 'auto', shift: [22, 10], slide: 15, className: 'settings_tt'})\">\r\n      </span>\r\n    </div>\r\n    <div class=\"rs_sl\">\r\n      <div class=\"checkbox on\" data-param-type=\"needInterval\" role=\"checkbox\" aria-checked=\"true\" tabindex=\"0\">\r\n        \u0418\u043D\u0442\u0435\u0440\u0432\u0430\u043B \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0438\r\n      </div>\r\n      <select class=\"rs-select interval\">\r\n        <option data-interval=\"1\">1\u0441</option>\r\n        <option data-interval=\"3\">3\u0441</option>\r\n        <option data-interval=\"5\" selected=\"selected\">5\u0441</option>\r\n        <option data-interval=\"10\">10\u0441</option>\r\n        <option data-interval=\"15\">15\u0441</option>\r\n        <option data-interval=\"30\">30\u0441</option>\r\n      </select>\r\n      <span class=\"hint_icon\" onmouseover=\"showTooltip(this, {text: '\u041F\u0440\u0438 \u043C\u0430\u0441\u0441\u043E\u0432\u043E\u0439 \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0435, \u0432\u043A \u043C\u043E\u0436\u0435\u0442 \u043E\u0433\u0440\u0430\u043D\u0438\u0447\u0438\u0442\u044C \u043D\u0430 \u0432\u0440\u0435\u043C\u044F \u0434\u043E\u0441\u0442\u0443\u043F \u043A \u043D\u0435\u043A\u043E\u0442\u043E\u0440\u044B\u043C \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u0430\u043C, \u0438\u0437-\u0437\u0430 \u0441\u043B\u0438\u0448\u043A\u043E\u043C \u0447\u0430\u0441\u0442\u044B\u0445 \u0437\u0430\u043F\u0440\u043E\u0441\u043E\u0432. \u0427\u0442\u043E\u0431\u044B \u044D\u0442\u043E\u0433\u043E \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044C, \u043C\u043E\u0436\u043D\u043E \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u0442\u044C \u044D\u0442\u043E\u0442 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440.', dir: 'auto', shift: [22, 10], slide: 15, className: 'settings_tt'})\">\r\n      </span>\r\n    </div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class h{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"photo\">\r\n  <div class=\"ui_thumb_x_button _close_btn\" role=\"link\" aria-label=\"\u041D\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u044F\u0442\u044C\">\r\n    <div class=\"ui_thumb_x\"></div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class i{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"audio\">\r\n  <div tabindex=\"0\" class=\"audio_row audio_row_with_cover _audio_row audio_can_add inlined audio_row2 rs_al\" data-full-id=\"%FULL_ID%\" onclick=\"return getAudioPlayer().toggleAudio(this, event)\" data-audio=\"%JSON_AUDIO%\" onmouseover=\"AudioUtils.onRowOver(this, event)\" onmouseleave=\"AudioUtils.onRowLeave(this, event)\">\r\n    <div class=\"audio_row_content _audio_row_content\">\r\n      <button class=\"blind_label _audio_row__play_btn\" aria-label=\"\u0412\u043E\u0441\u043F\u0440\u043E\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \" onclick=\"getAudioPlayer().toggleAudio(this, event); return cancelEvent(event)\"></button>\r\n\r\n      <div class=\"audio_row__cover\"></div>\r\n      <div class=\"audio_row__cover_back _audio_row__cover_back\"></div>\r\n      <div class=\"audio_row__cover_icon _audio_row__cover_icon\"></div>\r\n      <div class=\"audio_row__counter\"></div>\r\n      <div class=\"audio_row__play_btn\"></div>\r\n\r\n      <div class=\"audio_row__inner\">\r\n        <div class=\"audio_row__performer_title\">\r\n          <div onmouseover=\"setTitle(this)\" class=\"audio_row__performers\">\r\n            <a class=\"artist_link\" data-performer=\"%PERFORMER%\">PERFORMER</a>\r\n          </div>\r\n          <div class=\"audio_row__title _audio_row__title\" onmouseover=\"setTitle(this)\">\r\n            <span class=\"audio_row__title_inner _audio_row__title_inner\">TITLE</span>\r\n            <span class=\"audio_row__title_inner_subtitle _audio_row__title_inner_subtitle\"></span>\r\n          </div>\r\n        </div>\r\n        <div class=\"audio_row__info _audio_row__info\">\r\n          <div class=\"audio_row__duration audio_row__duration-s _audio_row__duration\">TIME</div>\r\n        </div>\r\n      </div>\r\n\r\n      <div class=\"audio_player__place _audio_player__place\"></div>\r\n    </div>\r\n  </div>\r\n  <div class=\"ui_thumb_x_button _close_btn rs_cl\" role=\"link\" aria-label=\"\u041D\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u044F\u0442\u044C\">\r\n    <div class=\"ui_thumb_x\"></div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class j{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"video\">\r\n  <div class=\"ui_thumb_x_button _close_btn\" role=\"link\" aria-label=\"\u041D\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u044F\u0442\u044C\">\r\n    <div class=\"ui_thumb_x\"></div>\r\n  </div>\r\n  <div class=\"video_thumb_label _has_play_icon rs_vl\">\r\n    <span class=\"video_thumb_label_item\">2:21:08</span>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class k{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"doc\">\r\n  <div class=\"docs_item _docs_item rs_dl\" id=\"\">\r\n    <a class=\"docs_item_icon\" ext=\"\" aria-label=\"\"></a>\r\n    <div class=\"docs_item_cont\">\r\n      <a class=\"docs_item_name\"></a>\r\n    </div>\r\n  </div>\r\n\r\n  <div class=\"ui_thumb_x_button _close_btn rs_cl\" role=\"link\" aria-label=\"\u041D\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u043B\u044F\u0442\u044C\">\r\n    <div class=\"ui_thumb_x\"></div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class l{constructor(b,c){const{stManager:d,checkbox:e}=unsafeWindow,{Storage:f,Api:l}=b;d.add(["docs.css","settings.css","tooltips.js"]);const m=g.createElement(),n={body:m,media_stash:[],input:m.querySelector("textarea"),photo_attach:m.querySelector(".ms_item_photo"),video_attach:m.querySelector(".ms_item_video"),audio_attach:m.querySelector(".ms_item_audio"),doc_attach:m.querySelector(".ms_item_doc"),checkboxes:Array.from(m.querySelectorAll(".checkbox")),interval_options:Array.from(m.querySelectorAll(".rs-select.interval > option")),saveData(a,b,d){f.saved[c]||(f.saved[c]={media:[],text:"",params:{},recievedList:{}}),"media"===a?!0===d?f.saved[c].media=f.saved[c].media.filter(a=>a[1]!==b[1]):f.saved[c].media.push(b):"text"===a?f.saved[c].text=b:"params"==a&&(f.saved[c].params=b),f.save()},getSendData(){const{input:a,media_stash:b}=this;return{text:a.value,media:b}},getSendParams(){const{checkboxes:a,interval_options:b}=this,c=a.filter(a=>"sendBy"===a.dataset.paramType&&"true"===a.getAttribute("aria-checked"))[0].dataset.sendType,d="true"===a.filter(a=>"needSubscribe"===a.dataset.paramType)[0].getAttribute("aria-checked"),e="true"===a.filter(a=>"countRecievedUsers"===a.dataset.paramType)[0].getAttribute("aria-checked"),f="true"===a.filter(a=>"needWebApi"===a.dataset.paramType)[0].getAttribute("aria-checked"),g="true"===a.filter(a=>"needInterval"===a.dataset.paramType)[0].getAttribute("aria-checked"),h=1e3*parseInt(b.filter(a=>!0===a.selected)[0].dataset.interval);return{sendType:c,needSubscribe:d,needWebApi:f,countRecievedUsers:e,needInterval:g,intervalValue:h}},addToStash(a){this.media_stash.push(a)},removeFromStash(a){this.media_stash.splice(this.media_stash.indexOf(a),1)},async addAttachment(b,c,d){const e=b+c;if(this.media_stash.includes(e))return;this.addToStash(e);const f=a=>{this.removeFromStash(e),this.saveData("media",[b,c,d],!0),a.remove()};if("photo"===b){const a=h.createElement();a.style.backgroundImage="url("+d.thumb_m+")",a.dataset.info=JSON.stringify(d),a.addEventListener("click",b=>{b.target===a&&window.open(location.pathname+"?z=photo"+c+"%2F"+d.list)});const b=a.querySelector("._close_btn");b.addEventListener("click",()=>{f(a)}),m.querySelector(".attachment-container > .photos").appendChild(a)}else if("video"===b){const a=j.createElement();a.dataset.info=JSON.stringify(d),a.style.backgroundImage="url("+d.thumb+")",a.addEventListener("click",b=>{b.target===a&&window.open("/video"+c)});const b=a.querySelector(".video_thumb_label_item");b.innerHTML=d.editable.duration;const e=a.querySelector("._close_btn");e.addEventListener("click",()=>{f(a)}),m.querySelector(".attachment-container > .videos").appendChild(a)}else if("audio"===b){const[,,,b,e,g]=d,h=i.createElement(),j=h.querySelector("div");j.dataset.fullId=c,j.dataset.audio=JSON.stringify(d),j.classList.add("_audio_row_"+c);const k=h.querySelector(".artist_link");k.innerHTML=e,k.dataset.performer=e,k.addEventListener("click",()=>{const a="/audio?performer=1&q="+encodeURIComponent(e);window.open(a)});const l=h.querySelector("._audio_row__title_inner");l.innerHTML=b;const n=h.querySelector("._audio_row__duration");n.innerHTML=a(g);const o=h.querySelector("._close_btn");o.addEventListener("click",()=>{f(h)}),m.querySelector(".attachment-container > .audios").appendChild(h)}else if("doc"===b){let{title:a,ext:b,type:e}=d;if("undefined"==typeof a||"undefined"==typeof b){const[d]=await l.req("docs.getById",{docs:c});a=d.title,b=d.ext}const g=k.createElement(),h=g.querySelector(".doc > div");h.id="docs_file_"+c;const i=h.querySelector("a");i.setAttribute("ext",b),i.setAttribute("aria-label",a),i.classList.add("docs_icon_type"+e),i.addEventListener("click",()=>{window.open("/doc"+c)});const j=h.querySelector(".docs_item_cont > a");j.setAttribute("title",a),j.innerHTML=a,j.addEventListener("click",()=>{window.open("/doc"+c)});const n=g.querySelector("._close_btn");n.addEventListener("click",()=>{f(g)}),m.querySelector(".attachment-container > .docs").appendChild(g)}this.saveData("media",[b,c,d])},addLoadState(a=""){const b=document.createElement("div");return b.classList.add("state"),b.dataset.filename=a,b.innerHTML="\u0417\u0430\u0433\u0440\u0443\u0437\u043A\u0430 "+a+"...",m.querySelector(".attachment-states").appendChild(b)},removeLoadState(a=""){const b=m.querySelector(".attachment-states").childNodes,c=Array.from(b).some(b=>{if(b.dataset===a)return b.remove(),!0});if(c)return!0;throw new Error},removeLastLoadState(){return m.querySelector(".attachment-states").firstChild.remove()}};if(f.saved[c]){const{media:a,text:b,params:d}=f.saved[c];a.forEach(([a,b,c])=>{n.addAttachment(a,b,c)}),n.input.value=b,n.checkboxes.forEach(a=>{const{paramType:b,sendType:c}=a.dataset,f="true"===a.getAttribute("aria-checked");if("sendBy"!==b)b&&!0===d[b]&&!1===f?e(a):b&&!1===d[b]&&!0===f&&e(a);else if(c!==d.sendType)!0===f&&e(a);else if(!1===f)e(a);else return})}return n.checkboxes.forEach(a=>{a.addEventListener("click",()=>{const{paramType:b}=a.dataset,c="true"===a.getAttribute("aria-checked");if("sendBy"===b&&!0===c)return;else{n.checkboxes.filter(a=>a.dataset.paramType===b).forEach(b=>{const c="true"===b.getAttribute("aria-checked");!0==c&&b!==a&&e(b)}),e(a);const c=n.getSendParams();n.saveData("params",c)}})}),n.input.addEventListener("input",()=>{n._inputTimeout&&clearTimeout(n._inputTimeout),n._inputTimeout=setTimeout(()=>{n._inputTimeout=null,n.saveData("text",n.input.value)},500)}),n.saveData("params",n.getSendParams()),m.querySelector(".header").addEventListener("click",()=>{console.log("DATA:",n.getSendData(),"PARAMS:",n.getSendParams())}),n}}class m{static createElement(){let a=document.createElement("template");return a.innerHTML="<div tabindex=\"0\" class=\"popup_box_container\">\r\n  <div class=\"box_layout\">\r\n    <div class=\"box_title_wrap\">\r\n      <div class=\"box_x_button\" aria-label=\"\u0417\u0430\u043A\u0440\u044B\u0442\u044C\" tabindex=\"0\" role=\"button\"></div>\r\n      <div class=\"box_title\">BOX_TITLE</div>\r\n    </div>\r\n    <div class=\"box_body\">BOX_BODY</div>\r\n    <div class=\"box_controls_wrap\">\r\n      <div class=\"box_controls\">\r\n        <table cellspacing=\"0\" cellpadding=\"0\" class=\"fl_r\">\r\n          <tbody>\r\n            <tr></tr>\r\n          </tbody>\r\n        </table>\r\n        <div class=\"progress\" id=\"box_progress4\"></div>\r\n        <div class=\"box_controls_text _box_controls_text\"></div>\r\n      </div>\r\n    </div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class n{static createElement(){let a=document.createElement("template");return a.innerHTML="<td>\r\n  <button class=\"flat_button\">TEXT</button>\r\n</td>".trim(),a.content.firstChild}}class o{constructor(){return this.createBox(...arguments)}createBox(a={}){const d=new c,{width:e,height:f,title:g,body:h}=a,{MessageBox:i,boxQueue:j}=unsafeWindow,k=i(),l=m.createElement();l.setAttribute("tabindex","0"),l.style.width="undefined"==typeof e?"450px":e+"px",l.style.height="undefined"==typeof f?"auto":f+"px",l.addEventListener("click",()=>{j.skip=!0});const o=k.bodyNode.parentNode,p=o.parentNode;p.replaceChild(l,o);const q=l.querySelector(".box_x_button"),r=l.querySelector(".box_title"),s=l.querySelector(".box_body"),t=l.querySelector(".box_title_wrap"),u=l.querySelector(".box_controls_wrap");u.style.display="none",k.titleWrap=t,k.bodyNode=s;const v={events:d,mBox:k,get body(){return k.bodyNode},show(){k._show(),j.curBox=k.guid,j._boxes.includes(k.guid)||j._boxes.push(k.guid),this.updateOffset()},close(a){let b=!0;a&&d.emit("beforeclose",{preventDefault(){b=!1}}),!0==b&&(q.removeEventListener("click",this.close),j._boxes.splice(j._boxes.indexOf(k.guid,1)),k._show(),k._hide(),d.emit("afterclose"))},hide(){k._hide(null,!0)},updateOffset(){const a=window.innerHeight/2-l.clientHeight/2;p.style.marginTop=80<a?a+"px":"80px"},setTitle(a){r.innerHTML=a,this.updateOffset()},setBody(a){"string"==typeof a?s.innerHTML=a:b(a)&&(s.innerHTML="",s.appendChild(a)),this.updateOffset()},addButton(a,b){const c=u.querySelector(".box_controls > table > tbody > tr"),d=n.createElement(),e=d.querySelector("button");e.innerHTML=a||"TEXT",e.addEventListener("click",()=>{b()}),"none"===u.style.display&&(u.style.display="block"),c.appendChild(e)}};return q.addEventListener("click",v.close),v.setTitle(g||"BOX TITLE"),v.setBody(h||"BOX BODY"),v}}var p=a=>new Promise(b=>setTimeout(b,a));class q{static createElement(){let a=document.createElement("template");return a.innerHTML="<div class=\"worker-body\">\r\n  <div class=\"log\"></div>\r\n\r\n  <div class=\"progress-container\">\r\n    <div class=\"percents-bar\">\r\n      0%\r\n    </div>\r\n    <div class=\"page_attach_progress ui_progress wr-pb\" style=\"display: block;\">\r\n      <div class=\"ui_progress_back\"></div>\r\n      <div class=\"ui_progress_bar\" style=\"width: 0%;\"></div>\r\n    </div>\r\n  </div>\r\n</div>".trim(),a.content.firstChild}}class r{constructor(){const a=q.createElement(),b={body:a,progress_bar:a.querySelector(".ui_progress_bar"),percents_bar:a.querySelector(".percents-bar"),worker_log:a.querySelector(".worker-body > .log"),setProgress(a,b){const{progress_bar:c,percents_bar:d}=this;d.innerHTML=`${a}%${b?" "+b:""}`,c.style.width=`${a}%`},log(a){const{worker_log:b}=this,c=document.createElement("div");c.innerHTML+=a,b.appendChild(c),260>b.scrollHeight-b.scrollTop&&(b.scrollTop=b.scrollHeight-b.clientHeight)},logOk(a){this.log(`[ОК] -> ${a}`)},logWarn(a){this.log(`[ВНИМАНИЕ] -> ${a}`)},logError(a){this.log(`[ОШИБКА] -> ${a.message?"MESSAGE: "+a.message+(a.stack?", STACK: "+a.stack:""):"object"==typeof a?JSON.stringify(a):a}`)},end(){const{progress_bar:a,percents_bar:b}=this;b.innerHTML="100% - \u0413\u043E\u0442\u043E\u0432\u043E!",a.parentNode.style.display="none"}};return b}}class s{constructor(a={}){const{rs:b,postId:d,needSubscribe:e,sendType:f,sendData:g,needWebApi:h,countRecievedUsers:i,needInterval:j,intervalValue:k}=a;this.rs=b,this.postId=d,this.needSubscribe=e,this.sendType=f,this.sendData=g,this.needWebApi=h,this.countRecievedUsers=i,this.needInterval=j,this.intervalValue=k,this.stopState=!1,this.endState=!1,this.events=new c,this.events.on("stop",()=>{this.stopState=!0}),this.events.on("end",()=>{this.endState=!0})}start(){const{vk:a}=unsafeWindow,{rs:b,postId:c,needSubscribe:e,sendType:f,sendData:g,needWebApi:h,countRecievedUsers:i,needInterval:j,intervalValue:k,events:l}=this,{Api:m,WebBindings:n,Storage:q}=b;let s=!1;l.on("stop",()=>{s=!0});const[t,u]=c.split("_"),v=new r,w=new o({title:"\u0420\u0430\u0441\u043F\u0438\u0441\u0430\u0442\u043E\u0440",body:v.body,width:500});return async function(){let b,o=[];if(v.logOk(`Рассылка по ${"repost"===f?"\u0440\u0435\u043F\u043E\u0441\u0442\u0430\u043C":"\u043B\u0430\u0439\u043A\u0430\u043C"}`),v.logOk(`Интервал рассылки: ${j?k/1e3+"c":"\u043D\u0435 \u0443\u0441\u0442\u0430\u043D\u043E\u0432\u043B\u0435\u043D"}`),v.logOk("\u041F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u0435 \u0441\u043F\u0438\u0441\u043A\u0430..."),b=await async function a(b){if(!0===s)return!0;else{const c=1e3;try{const d=await m.req("likes.getList",{count:c,type:"post",filter:"like"===f?"likes":"copies",owner_id:t,item_id:u,offset:b});return o.push(...d.items),v.logOk(`Получение списка [${o.length}/${d.count}]`),!!(d.count>b+c)&&(await a(b+c))}catch(a){v.logError(a)}}}(0),!0===b)return void console.log("STOP DETECTED");if(0===o.length)v.logError("\u0421\u043F\u0438\u0441\u043E\u043A \u043F\u0443\u0441\u0442! \u0420\u0430\u0441\u0441\u044B\u043B\u043A\u0430 \u043D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u0430!");else{if(v.logOk("\u0421\u043F\u0438\u0441\u043E\u043A \u043F\u043E\u043B\u0443\u0447\u0435\u043D"),!0===e&&t.startsWith("-")){const a=500,c=[];if(b=await async function b(d){if(!0===s)return!0;else{const e=await m.req("groups.isMember",{count:a,user_ids:o.slice(d,d+a),group_id:t.substr(1)}),f=e.filter(a=>1===a.member).map(a=>a.user_id);return c.push(...f),!!(e.count>d+a)&&(await b(d+a))}}(0),!0===b)return void console.log("STOP DETECTED");const d="like"===f?"\u043B\u0430\u0439\u043A\u043D\u0443\u0432\u0448\u0438\u0445":"\u0440\u0435\u043F\u043E\u0441\u0442\u043D\u0443\u0432\u0448\u0438\u0445",e=o.length-c.length;0<e&&v.logWarn(`${e} человек(а) из ${d} не подписан(ы)`),o=c}else!1!==e||t.startsWith("-")||v.logWarn("\u041F\u043E\u0434\u043F\u0438\u0441\u043A\u0438 \u043C\u043E\u0436\u043D\u043E \u0443\u0447\u0438\u0442\u044B\u0432\u0430\u0442\u044C \u0442\u043E\u043B\u044C\u043A\u043E \u0432 \u0433\u0440\u0443\u043F\u043F\u0435");if(!0===i){const a=Object.keys(q.saved[c].recievedList);if(0<a.length){const b=o.filter(b=>!a.includes(b.toString()));v.logOk(`Пропущено ${o.length-b.length} из ${o.length} (получившие роспись)`),o=b}}else q.saved[c].recievedList={},q.save();if(v.logOk(`Итого пользователей: ${o.length}`),v.logOk("\u041D\u0430\u0447\u0438\u043D\u0430\u0435\u043C \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0443..."),b=await async function(){for(let b=0;b<o.length;b++){const f=o[b];if(f==a.id)continue;else{if(!0===s)return!0;v.setProgress(d(100*(b/o.length)),`[${b+1}/${o.length}]`);try{!0===h?await n.wallPost({owner_id:f,message:g.text,attachments:g.media}):await m.req("wall.post",{owner_id:f,message:g.text,attachments:g.media.join(",")}),q.saved[c].recievedList[f]=!0,q.save(),v.logOk(`Пользователь <a href="/id${f}">${f}</a> - запись сделана`)}catch(a){!0===h&&"8"==a[0]?v.logError(`Пользователь <a href="/id${f}">${f}</a> - ${a[1][0]}`):a.error&&a.error.error_msg?v.logError(`Пользователь <a href="/id${f}">${f}</a> - ${a.error.error_msg} (${a.error.error_code})`):(v.logError(`Пользователь <a href="/id${f}">${f}</a> - запись не сделана`),v.logError(a))}if(b===o.length-1)continue;else!0===j&&(await p(k))}}}(),!0===b)return void console.log("STOP DETECTED");v.logOk("\u0420\u0430\u0441\u0441\u044B\u043B\u043A\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u0430!")}v.end(),w.addButton("\u0417\u0430\u043A\u0440\u044B\u0442\u044C",()=>{w.close(!0)}),l.emit("end")}(),w.show(),w}}class t{static _setCurHandlers(a={}){const{onMediaChoose:b,onMediaProgress:c,attachCount:d}=a,{cur:e}=unsafeWindow;e.chooseMedia=b,e.chooseMedia.pbind=e.chooseMedia.bind,e.attachCount=d,e.showMediaProgress=c}static _loadAudioPage(){const{stManager:a}=unsafeWindow;return new Promise(b=>{const{AudioPage:c}=unsafeWindow;"undefined"==typeof c?(console.log("page is undefined, loading..."),a.add(["audio.js","indexer.js","auto_list.js","grid_sorter.js","audio.css"],function(){const{cur:a}=unsafeWindow;a.audioAttachOriginalOwnerId=!1,a.audioAttachSwitchOwnerId=!1,b(!0)})):(console.log("page is defined"),b(!0))})}static getCurrentPhotoMax(){const{pvCurPhoto:a}=unsafeWindow.cur;return a.w_src||a.z_src||a.y_src||a.x_src||a.m_src||a.s_src}static getPhotoMax(a){let b={height:0,width:0};return a.forEach(a=>{(a.height>b.height||a.width>b.width)&&(b=a)}),b}static showPhotoAttachBox(a={}){const{limit:b}=a,{showBox:c}=unsafeWindow;return this._setCurHandlers(a),c("al_photos.php",{act:"choose_photo",mail_add:"",max_files:b||10,no_album_select:1,to_id:!1})}static showVideoAttachBox(a={}){const{limit:b}=a,{showBox:c}=unsafeWindow;return this._setCurHandlers(a),c("al_video.php",{act:"a_choose_video_box",mail_add:"",max_files:b||10,no_album_select:1,to_id:!1})}static showDocAttachBox(a={}){const{limit:b}=a,{showBox:c}=unsafeWindow;return this._setCurHandlers(a),c("docs.php",{act:"a_choose_doc_box",mail_add:"",max_files:b||10,no_album_select:1,to_id:!1})}static async showAudioAttachBox(a={}){this._setCurHandlers(a),await this._loadAudioPage();const{AudioPage:b,AudioUtils:c,vk:d}=unsafeWindow;return b.showAttachBox(d.id,{canPlaylistAttach:!0,onAudioChoose:c.onAudioChoose,onPlaylistChoose:c.onPlaylistChoose})}static showDoneBox(a){const{showDoneBox:b}=unsafeWindow;b(a,{w:420})}static alertMaxFiles(){const{showDoneBox:a,cur:b}=unsafeWindow;a(2==b.chooseParams.maxFiles&&0?"\u0412\u044B \u043D\u0435 \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0431\u043E\u043B\u0435\u0435 2 \u0432\u043B\u043E\u0436\u0435\u043D\u0438\u0439 \u043A \u043E\u0434\u043D\u043E\u043C\u0443 \u043A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u044E.":"\u0412\u044B \u043D\u0435 \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u044C \u0431\u043E\u043B\u0435\u0435 10 \u0432\u043B\u043E\u0436\u0435\u043D\u0438\u0439 \u043A \u043E\u0434\u043D\u043E\u0439 \u0437\u0430\u043F\u0438\u0441\u0438.",{w:420})}}class u{constructor(a){this.rs=a}load(a){const{rs:b}=this,c=new l(b,a),d=new o({title:"\u0420\u0430\u0441\u043F\u0438\u0441\u0430\u0442\u043E\u0440",body:c.body,width:500}),e={onMediaChoose(a,b,e){const{boxQueue:f,cur:g}=unsafeWindow;return"object"==typeof b&&(e=b,b=a,a="photo"),console.log("MEDIA CHOSEN",arguments,d),console.log("TYPE:",a,"ID:",b,"INFO:",e),g.selectedCount&&(0!==g.selectedCount()||f.curBox===d.mBox.guid)||f.hideLast(),c.addAttachment(a,b,e),!1},onMediaProgress(a,b,d){if(console.log("MEDIA PROGRESS",arguments),0===d.total)c.addLoadState(d.fileName);else if(d.total===d.loaded)try{c.removeLoadState(d.fileName)}catch(a){c.removeLastLoadState()}return!1},attachCount(){return c.media_stash.length}};c.photo_attach.addEventListener("click",()=>{10<=c.media_stash.length?t.alertMaxFiles():t.showPhotoAttachBox(e)}),c.video_attach.addEventListener("click",()=>{10<=c.media_stash.length?t.alertMaxFiles():t.showVideoAttachBox(e)}),c.audio_attach.addEventListener("click",()=>{10<=c.media_stash.length?t.alertMaxFiles():t.showAudioAttachBox(e)}),c.doc_attach.addEventListener("click",()=>{10<=c.media_stash.length?t.alertMaxFiles():t.showDocAttachBox(e)}),d.addButton("\u041D\u0430\u0447\u0430\u0442\u044C",()=>{const{needSubscribe:e,sendType:f,needWebApi:g,countRecievedUsers:h,needInterval:i,intervalValue:j}=c.getSendParams(),k=c.getSendData();if(""===k.text&&0===k.media.length)t.showDoneBox("\u041D\u0435\u043B\u044C\u0437\u044F \u0440\u0430\u0441\u0441\u044B\u043B\u0430\u0442\u044C \u043F\u0443\u0441\u0442\u044B\u0435 \u0437\u0430\u043F\u0438\u0441\u0438 (\u043F\u0440\u0438\u043A\u0440\u0435\u043F\u0438\u0442\u0435 \u0445\u043E\u0442\u044F-\u0431\u044B \u043E\u0434\u0438\u043D \u0444\u0430\u0439\u043B, \u0438\u043B\u0438 \u043D\u0430\u043F\u0438\u0448\u0438\u0442\u0435 \u043E\u0434\u0438\u043D \u0441\u0438\u043C\u0432\u043E\u043B)");else{d.hide(),console.log("PARAMS:",c.getSendParams()),console.log("DATA:",c.getSendData());const l=new s({rs:b,postId:a,needSubscribe:e,sendType:f,sendData:k,needWebApi:g,countRecievedUsers:h,needInterval:i,intervalValue:j}),m=l.start();m.events.on("beforeclose",a=>{if(a.preventDefault(),!0===l.endState)m.close(),d.close();else{const a=new o({title:"\u0420\u0430\u0441\u043F\u0438\u0441\u0430\u0442\u043E\u0440",body:"\u0412\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u043E \u0445\u043E\u0442\u0438\u0442\u0435 \u043F\u0440\u0435\u0440\u0432\u0430\u0442\u044C \u043F\u0440\u043E\u0446\u0435\u0441\u0441 \u0440\u0430\u0441\u0441\u044B\u043B\u043A\u0438?"});a.events.on("beforeclose",a=>{a.preventDefault()}),a.addButton("\u0414\u0430",()=>{l.stop(),a.close(),m.close(),d.show()}),a.addButton("\u041D\u0435\u0442",()=>{a.close(),m.show()}),m.hide(),a.show()}}),m.events.on("afterclose",()=>{d.show()})}}),d.show()}}class v{static createElement(){let a=document.createElement("template");return a.innerHTML="<a class=\"ui_actions_menu_item\">TEXT</a>".trim(),a.content.firstChild}}class w{constructor(a){const b=v.createElement();return b.innerHTML=a||"null",b}}class x{constructor(a){this.rs=a}postHandler(a){const b=a.dataset&&a.dataset.postId;if("undefined"!=typeof b){const c=a.querySelector(".ui_actions_menu"),d=new w("\u0420\u0430\u0441\u043F\u0438\u0441\u0430\u0442\u043E\u0440");d.addEventListener("click",()=>{const{rs:a}=this,c=new u(a);c.load(b)}),c.appendChild(d)}}}class y{constructor(a){this.rs=a,this.wall=new x(a)}}class z{constructor(a){this.rs=a,this.modifiers=new y(a)}init(){const a=new f;a.on("WallPost",a=>{this.modifiers.wall.postHandler(a)})}}class A{static stringify(a,b){if("object"==typeof a)return Object.entries(a).map(c=>(b||(c[1]=encodeURIComponent(c[1])),c.join("="))).join("&");throw"Error: parameter must be an object"}static parse(a){const b=a.match(/[A-z%0-9\-.]+=[A-z%0-9\-.]+/g);if(!b)return null;else{const a={};return b.forEach(b=>{const c=b.split("=");a[c[0]]=c[1]}),a}}}class B{static async get(a,b,c){const d=new XMLHttpRequest;return b&&(a+="?"+A.stringify(b)),d.open("GET",a,!0),c&&Object.entries(c).forEach(a=>{d[a[0]]=a[1]}),d.send(),new Promise((a,b)=>{d.onreadystatechange=()=>{4!=d.readyState||(200===d.status?a(d.response):b(d))}})}static async post(a,b,c){const d=new XMLHttpRequest;d.open("POST",a,!0);let{headers:e,formData:f,body:g}=b;if(e&&Object.entries(e).forEach(a=>{d.setRequestHeader(a[0],a[1])}),!0===f){const a=new FormData;Object.entries(g).forEach(b=>{a.append(b[0],b[1])}),g=a}return c&&Object.entries(c).forEach(a=>{d[a[0]]=a[1]}),d.send(g||""),new Promise((a,b)=>{d.onreadystatechange=()=>{4!=d.readyState||(200===d.status?a(d.responseText):b(d))}})}}class C{constructor(a){this.cart=[];const{cart:b}=this;setInterval(()=>{if(b.length){const[a,c,d]=b.shift();a().then(c).catch(d)}},a||334)}addToQueue(a,b,c){this.cart.push([a,b,c])}}class D{constructor(a){this.vvk=a,this.hash=null,this.cart=new C(334)}async req(a,c={}){if(!this.hash){let d=await B.get("https://vk.com/dev/execute"),b=d.match(/Dev\.methodRun\('([A-z0-9:]+)/i);if(b)return this.hash=b[1],this.req(a,c);throw"user isn't logged"}else{let b={act:"a_run_method",al:1,method:"execute",param_v:"5.101",hash:this.hash};if("execute"==a)for(let a in c)b["param_"+a]=c[a];else b.param_code="return API."+a+"("+JSON.stringify(c)+");";let d=async()=>{let d,e=await B.post("https://vk.com/dev",{headers:{"Content-Type":"application/x-www-form-urlencoded"},body:A.stringify(b)}),f=e.replace(/^<!-+/,"").split("<!>");if(1===f.length?d=JSON.parse(f[0]).payload:(f.splice(f.indexOf(f[4]),1),f.splice(f.indexOf(f[5]),1),d=[f[4],f]),console.log("PAYLOAD:",d),0==d[0]){let a=JSON.parse(d[1]);if(a.payload&&a.payload[1]&&(a=JSON.parse(a.payload[1][0])),a.error)throw a;else return a.response||a}else{if(8==d[0])return this.hash=null,this.req(a,c);throw console.log("UNKNOWN API ERROR: ",e),"unknown api error"}};return new Promise((a,b)=>{this.cart.addToQueue(d,a,b)})}}}var E={defaults:{saved:{},post_states:{}},settingsName:"raspisator-data"};const F=Object.assign(E.defaults,JSON.parse(unsafeWindow.localStorage.getItem(E.settingsName))||{}),G=new Proxy(F,{get(a,b){return"save"===b?()=>{unsafeWindow.localStorage.setItem(E.settingsName,JSON.stringify(F))}:a[b]},set(a,b,c){return F[b]=c,!0}});class H{constructor(){}async req(a,b){const c=`https://vk.com${a.startsWith("/")?a:"/"+a}`,d=await B.post(c,{formData:!0,body:b});let e,f=d.replace(/^<!-+/,"").split("<!>");if(1===f.length?e=JSON.parse(f[0]).payload:(f.splice(f.indexOf(f[4]),1),f.splice(f.indexOf(f[5]),1),e=[f[4],f]),"8"==e[0])throw e;else return e}async wallPost(a={}){let{owner_id:b,attachments:c,message:d}=a;const e={act:"post",to_id:b,type:"all",mark_as_ads:0,update_admin_tips:0,hash:null,Message:d,al:1};"string"==typeof c&&(c=c.split(",")),"object"==typeof c&&null!==c&&c.forEach((a,b)=>{const c=a.match(/^[A-z]+/)[0],d=a.replace(c,""),f=b+1;e["attach"+f+"_type"]=c,e["attach"+f]=d});let f;const g=parseInt(b);f=0>g?"club":"id";const h=await B.get(`https://vk.com/${f}${b}`),i=h.match(/"post_hash":"(.+?)"/);if(null!==i)return e.hash=i[1],this.req("/al_wall.php",e);throw{message:"Post hash is not defined"}}}new class{constructor(){this.Storage=G,this.Api=new D,this.WebBindings=new H,this.Controller=new z(this)}start(){console.log("VVK-Raspisator Started"),e.load(),this.Controller.init()}}().start()})();