window.requestFileSystem||(window.requestFileSystem=window.webkitRequestFileSystem);window.BlobBuilder||(window.BlobBuilder=window.WebKitBlobBuilder);
Registry.require("promise layout xmlhttprequest convert crcrc curtain layout/default/tabview layout/default/htmlutil helper i18n parser statistics layout/default/layout_helper".split(" "),function(){var y=rea.FEATURES,B=Registry.get("promise"),p=Registry.get("crcrc").cr,c=Registry.get("crcrc").crc,d=Registry.get("i18n"),C=Registry.get("curtain"),v=Registry.get("helper"),L=Registry.get("layout/default/tabview"),u=Registry.get("layout/default/htmlutil"),W=Registry.get("statistics"),G=Registry.get("layout"),
M=Registry.get("layout/default/layout_helper"),D=M.images;G.render(function(){M.addStyle();var k=null,t={},N="???",E=null,O="0.0.0",z=function(){var a=document.getElementById("ask"),b=c("div","content_wrapper","ask","main");if(a){var e=a.parentNode;e.removeChild(a);e.appendChild(b);$(document.body).addClass("main")}var a=c("div","head_container","ask","head_container"),e=c("div","tv_container_fit","ask","tv_container"),h=p("a","head_link","ask","head_link");h.href="https://tampermonkey.net";h.target=
"_blank";var f=c("div","float","ask","head1"),g=c("img","banner","ask");g.src=rea.extension.getURL("images/icon128.png");var d=c("div","float head","ask","head2"),l=c("div","header_title","heading"),m=c("div","version","version","version");m.textContent=" by Jan Biniok";var F=p("div","search","box","");l.innerHTML="Tampermonkey<sup>\u00ae</sup>";f.appendChild(g);d.appendChild(l);d.appendChild(m);h.appendChild(f);h.appendChild(d);a.appendChild(h);a.appendChild(F);b.appendChild(a);b.appendChild(e);
b=L.create("_main",e);a=p("div","main","main","tab_content_h");a.textContent=N;e=p("div","main","main","tab_content");b.appendTab(v.createUniqueId("main","main"),a,e).select();C.hide();return e},X=function(a){var b=a.script,e=a.oldscript,h=c("div","viewer_bottom_tab","bottom","");a={tv:"tv tv_alt",tv_table:"tv_table tv_table_alt",tr_tabs:"tr_tabs tr_tabs_alt",tr_content:"tr_content tr_content_alt",td_content:"td_content td_content_alt",td_tabs:"td_tabs td_tabs_alt",tv_tabs_align:"tv_tabs_align tv_tabs_align_alt",
tv_tabs_fill:"tv_tabs_fill tv_tabs_fill_alt",tv_tabs_table:"tv_tabs_table tv_tabs_table_alt",tv_contents:"tv_contents tv_contents_alt",tv_tab_selected:"tv_tab tv_selected tv_tab_alt tv_selected_alt",tv_tab_close:"",tv_tab:"tv_tab tv_tab_alt",tv_content:"tv_content tv_content_alt"};if(t.editor_enabled){var f=L.create("_source"+b.uuid,h,a),g,n=function(b,a){var h=c("div","tv_content tv_content_alt",b.uuid,a+"container_o"),e=c("table","editor_container_o editor_400p_container_o p100100 noborder",b.uuid,
a+"container_o"),g=c("tr","editor_container p100100",b.uuid,a+"container");h.appendChild(e);e.appendChild(g);var e=c("td","editor_outer editor_400p_outer",b.uuid,a+"edit"),f=c("div","editor_100 editor_border",b.uuid,a+"edit");g.appendChild(e);e.appendChild(f);return{c:h,e:f}},l=function(){var b=B();G.addStyle("vendor/cm/mode/diff/diff.css");Registry.vendor(["vendor/jsdiff/diff","vendor/cm/mode/diff/diff"],function(){l=B.Pledge;b.resolve()});return b.promise()};(function(){return e?l().then(function(){var a=
p("div",b.uuid,"diff_h");a.textContent=d.getMessage("Changes");var c=n(b,"diff");h.diff=new MirrorFrame(c.e,{theme:"diff",fontSize:t.editor_fontSize,value:d.getMessage("Please_wait___"),noButtons:!0,mode:"diff",readOnly:!0});g=f.appendTab("diff",a,c.c,function(){window.setTimeout(function(){h.diff.refresh();h.diff.mirror.focus()},1)});window.setTimeout(function(){var a;try{a=window.JsDiff.createTwoFilesPatch(d.getMessage("Current_Version"),d.getMessage("New_Version"),e.textContent,b.textContent,void 0,
void 0,{timeout:4E3})}catch(c){console.warn(c)}a||(a=d.getMessage("The_diff_for_this_script_is_too_large_to_render"));h.diff.mirror.setValue(a)},500)}):B.Pledge()})().then(function(){var a=p("div",b.uuid,"source_h");a.textContent=d.getMessage("Source_Code");var c=n(b,"source");h.editor=new MirrorFrame(c.e,{theme:t.editor_theme,fontSize:t.editor_fontSize,value:b.textContent,noButtons:!0,matchBrackets:!0,readOnly:!0});a=f.appendTab("source",a,c.c,function(){window.setTimeout(function(){h.editor.refresh();
h.editor.mirror.focus()},1)});g=g||a}).then(function(){g.select()})}else{var m=c("div","editor_400p_outer","editor",b.name);a=c("div","editor_400p editor_border","editor",b.name);h.appendChild(m);m.appendChild(a);m=c("textarea","editorta","editor",b.name);m.setAttribute("wrap","off");a.appendChild(m);m.value=b.textContent}return h},Y=function(){var a={};window.addEventListener("keydown",function(b){var c=!1;if("keydown"==b.type&&(a[b.keyCode]&&(c=a[b.keyCode](b)),c))return b.stopPropagation(),b.preventDefault(),
!1},!0);return{registerListener:function(b,c){a[b]=c}}}(),w=function(a,b,c){v.select(c,function(a){return a.label}).forEach(function(c){var e=c.icon?u.createImageTextButton(c.id,c.id,c.label,c.icon,c.fn):u.createButton(c.label,c.id,c.label,c.fn),g=$(e);g.addClass(b);c.id&&g.attr("data-btn-id",c.id);a.appendChild(e);c.focus&&window.setTimeout(function(){g.focus()},300);c.keyDown&&Y.registerListener(c.keyDown.keyCode?c.keyDown.keyCode:c.keyDown,c.keyDown.cb?c.keyDown.cb:c.fn)})},aa=function(a){var b=
a.script,e=c("div","viewer_last","install"),h=c("div","viewer_content","install_content"),f=c("div","ask_action_buttons","install_buttons"),g=[];g.push({label:a.messages.action,fn:function(){q(k.aid,"install")},focus:!0});y.RUNTIME.CHROME&&21>y.RUNTIME.BROWSER_VERSION&&g.push({label:a.messages.flags.install?d.getMessage("Process_with_Chrome"):null,fn:function(){Z(b.fileURL);$(e).hide()}});g.push({label:d.getMessage("Cancel"),fn:x,keyDown:27});w(f,"install",g);h.appendChild(f);e.appendChild(h);return e},
ba=function(a){var b=c("div","viewer_last","import"),e=c("div","viewer_content","import_content"),h=c("div","ask_action_buttons import_buttons","import_buttons");w(h,"import",[{label:d.getMessage("Import"),fn:function(){var b=Object.keys(a.scripts).filter(function(a){return!!$("input[type=checkbox][data-import-id="+a+"]:checked").val()}),c=a.global_settings&&!!$("input[type=checkbox][data-import-id=global_settings]:checked").val();q(k.aid,"import",{data:{import_ids:b,global_settings:c}})},focus:!0},
{label:d.getMessage("Cancel"),fn:x,keyDown:27}]);e.appendChild(h);b.appendChild(e);e=c("div","section","btn");e.appendChild(b);return e},ca=function(a){a=c("div","viewer_last","ok");var b=c("div","viewer_content","ok_content"),e=c("div","ask_action_buttons","ok_buttons");w(e,"import",[{label:d.getMessage("Ok"),fn:x,focus:!0}]);b.appendChild(e);a.appendChild(b);return a},da=function(a,b){var e=c("div","viewer_last","ok"),h=c("div","viewer_content","ok_content"),f=c("div","ask_action_buttons","ok_buttons");
w(f,"permission",[{label:d.getMessage("Ok"),fn:function(){rea.permissions.request({permissions:[b.permission]},function(a){rea.runtime.lastError&&console.warn("notify: error on getting permission",b.permission+"!","reason:",rea.runtime.lastError.message);q(k.aid,"permission",{data:{granted:a,permission:b.permission}})})},focus:!0},{label:d.getMessage("Cancel"),fn:x,keyDown:27}]);h.appendChild(f);e.appendChild(h);var h=c("div","viewer_upper","permission"),f=c("div","viewer_info viewer_info_wide","general",
"permission"),g=c("div","viewer_content","general_content","permission"),n=p("h3","install","heading","permission"),l=p("span","install","heading_span","permission"),m=c("span","message","heading","permission");document.title=l.textContent=b.title;m.textContent=b.message;n.appendChild(l);g.appendChild(m);f.appendChild(n);f.appendChild(g);h.appendChild(f);f=c("div","section","perm_src","permission");f.appendChild(h);f.appendChild(e);a.appendChild(f)},fa=function(a,b){var e=Date.now(),h,f;b.timeout&&
(h=window.setTimeout(function(){x();g()},b.timeout));var g=function(){var a;f&&window.clearInterval(f);h&&window.clearTimeout(h);f=h=null;(a=$("input[data-btn-id]")[0])&&a.parentNode.removeChild(a)},n=c("div","viewer_last","ok"),l=c("div","viewer_content","ok_content"),m=c("div","ask_action_buttons","ok_buttons"),F=c("div","ask_action_buttons","ok_buttons"),r=c("div","ask_action_buttons","ok_buttons");w(m,"connect",[{label:d.getMessage("Allow_once"),icon:"button_ok",fn:function(){return q(k.aid,"connect",
{data:{ok:!0,allow:!0,once:!0}})},focus:!0},{label:d.getMessage("Temporarily_allow"),icon:"clock",fn:function(){return q(k.aid,"connect",{data:{ok:!0,allow:!0,temporary:!0}})}},{label:b.hostname!=b.domain?d.getMessage("Always_allow"):d.getMessage("Always_allow_domain"),icon:"yes_domain",fn:function(){return q(k.aid,"connect",{data:{ok:!0,allow:!0}})}},function(){return b.domain&&b.hostname!=b.domain?{label:d.getMessage("Always_allow_domain"),icon:"yes_domain",fn:function(){return q(k.aid,"connect",
{data:{ok:!0,allow:!0,whole_domain:!0}})}}:null}(),function(){return b.all_domains?{label:d.getMessage("Always_allow_all_domains"),icon:"critical",fn:function(){g();if(window.confirm(d.getMessage("This_gives_this_script_the_permission_to_retrieve_and_send_data_from_and_to_every_webpage__This_is_potentially_unsafe__Are_you_sure_you_want_to_continue_")))return q(k.aid,"connect",{data:{ok:!0,allow:!0,all_domains:!0}})}}:null}()].filter(function(a){return a}));w(F,"connect",[{label:d.getMessage("Forbid_once"),
icon:"cancel",fn:function(){return q(k.aid,"connect",{data:{ok:!0,deny:!0,once:!0}})},keyDown:27},{label:b.hostname!=b.domain?d.getMessage("Always_forbid"):d.getMessage("Always_forbid_domain"),icon:"no_domain",fn:function(){return q(k.aid,"connect",{data:{ok:!0,deny:!0}})}},function(){return b.domain&&b.hostname!=b.domain?{label:d.getMessage("Always_forbid_domain"),icon:"no",fn:function(){return q(k.aid,"connect",{data:{ok:!0,deny:!0,whole_domain:!0}})}}:null}(),{label:d.getMessage("Dont_ask_again"),
icon:"no",fn:function(){return q(k.aid,"connect",{data:{ok:!0,deny:!0,all_domains:!0}})}}].filter(function(a){return a}));w(r,"connect_misc",[function(){return b.tabid?{label:d.getMessage("Focus_tab"),icon:"windowlist",fn:function(){ea("focus_tab",{tabid:b.tabid})}}:null}(),function(){if(b.timeout)return f=window.setInterval(function(){var a;(a=$("input[data-btn-id]")[0])&&$(a).attr("value",d.getMessage("Skip_timeout__0seconds0_seconds_",Math.round((b.timeout+e-Date.now())/1E3)))},1E3),{label:d.getMessage("Skip_timeout__0seconds0_seconds_",
Math.round(b.timeout/1E3)),id:"skip_timeout_button",fn:g}}()].filter(function(a){return a}));var u=c("div","viewer_upper","connect"),H=c("div","viewer_info viewer_info_wide","general","connect"),t=c("div","viewer_content","general_content","connect"),P=p("h3","install","heading","connect"),I=p("span","install","heading_span","connect"),Q=c("span","message","heading","connect");if(b.script.icon){var A=p("img","version","heading","connect");A.src=b.script.icon;I.appendChild(A)}document.title=I.textContent=
d.getMessage("A_userscript_wants_to_access_a_cross_origin_resource_");var A=c("div","ask_action_buttons message","help","connect"),R=p("div","help","connect"),J=d.getMessage("A_request_to_a_cross_origin_resource_is_nothing_unusual__You_just_have_to_check_whether_this_script_has_a_good_reason_to_access_this_domain__For_example_there_are_only_a_very_few_reasons_for_a_userscript_to_contact_your_bank__Please_note_that_userscript_authors_can_avoid_this_dialog_by_adding_@connect_tags_to_their_scripts__You_can_change_your_opinion_at_any_time_at_the_scripts_settings_tab_",
b.connect_url,b.settings_url),J=J.replace(/>/g,"&gt;").replace(/</g,"&lt;").replace(/\[url=([^\]]+)\](.*)\[\/url\]/g,'<a target="_blank" href="$1">$2 &#x2B00;</a>').replace(/\n/g,"<br>");R.innerHTML=J+"<br><br>";A.appendChild(R);P.appendChild(I);l.appendChild([r,A,m,F]);n.appendChild(l);var S=c("table","script_desc","connect");[{prop:"name",label:d.getMessage("Name")},{prop:"src_url",label:d.getMessage("Tab_URL")},b.domain?{prop:"hostname",label:d.getMessage("Destination_domain")}:null,{prop:"url",
label:d.getMessage("Destination_URL")}].forEach(function(a){if(a){var e=b[a.prop]||b.script[a.prop]||a.value,g=c("tr","script_desc",a.prop,"connect"),h=c("td","script_desc",a.prop,"connectdt"),f=c("td","script_desc",a.prop,"connectdd");h.textContent=a.label?a.label:"";f.textContent=e||d.getMessage("_not_set_");g.appendChild(h);g.appendChild(f);S.appendChild(g)}});Q.appendChild(S);t.appendChild(Q);H.appendChild(P);H.appendChild(t);u.appendChild(H);l=c("div","section","connect_src","connect");l.appendChild(u);
l.appendChild(n);a.appendChild(l)},ha=function(a,b){document.title=d.getMessage("Import");a.appendChild(ba(b));if(b.global_settings){var e=c("div","viewer_upper","");ga({content:e,checkbox:"import",key:"global_settings"});a.appendChild(e)}b.scripts&&Object.keys(b.scripts).forEach(function(e){var f=b.scripts[e],g=c("div","viewer_upper",e);K({content:g,preparat:f,checkbox:"import",key:e},!0);a.appendChild(g)})},T=function(a,b){var c=p("input",a+"_",b,"",!0);c.setAttribute("data-import-id",b);c.checked=
!0;c.type="checkbox";c.addEventListener("click",function(a){(a.ctrlKey||a.metaKey)&&$("input[type=checkbox][data-import-id!="+b+"]").prop("checked",c.checked)});return c},ga=function(a){var b=a.key,e=a.content,h=c("div","viewer_upper",b),f=c("div","viewer_info viewer_info_wide","general",b),g=c("div","viewer_content","general_content",b),n=p("h3","install","heading",b);a.checkbox&&n.appendChild(T(a.checkbox,a.key));a=p("img","version","heading",b);a.src=rea.extension.getURL("images/icon128.png");
n.appendChild(a);a=p("span","name","heading",b);a.textContent=d.getMessage("Global_Settings");n.appendChild(a);f.appendChild(n);n=c("table","script_desc",b);a=c("tr","settings_desc","action",b);var l=c("td","settings_desc","action",b+"dt"),m=c("td","settings_desc","action",b+"dd");l.textContent=d.getMessage("Action");m.textContent=d.getMessage("Global_settings_import");a.appendChild(l);a.appendChild(m);n.appendChild(a);a=c("tr","settings_desc","warning",b);l=c("td","settings_desc","warning",b+"dt");
m=c("td","settings_desc","warning",b+"dd");b='<i class="far fa-'+D.get("critical")+'"></i>&nbsp;';y.RUNTIME.MOBILE||(l.innerHTML=b,b="");m.innerHTML=b+u.safeTagsReplace(d.getMessage("This_will_overwrite_your_global_settings_"));a.appendChild(l);a.appendChild(m);n.appendChild(a);g.appendChild(n);f.appendChild(g);h.appendChild(f);f=c("div","section","settings_src");f.appendChild(h);e.appendChild(f)},K=function(a,b){var e=a.preparat,h=a.content,f=e.script||{},g=f.uuid||f.id||f.name;e.short_info||(e.short_info=
[]);var n=c("div","viewer_upper",g),l=c("div","viewer_info "+(b?"viewer_info_wide":"viewer_info_multiple"),"general",g),m=c("div","viewer_content","general_content",g),k=p("h3","install","heading",g);a.checkbox&&k.appendChild(T(a.checkbox,a.key));if(f.icon||f.icon64){var r=p("img","version","heading",g);r.src=f.icon||f.icon64;k.appendChild(r)}r=p("span","name","heading",g);r.textContent=e.heading||f.name||"";k.appendChild(r);f.version&&(r=c("span","view_version","heading",g),r.textContent="v"==f.version[0]?
"":"v",r.textContent+=f.version,k.appendChild(r));l.appendChild(k);b&&e.short_info.unshift({prop:"heading",value:e.messages.heading,label:d.getMessage("Action")});var q=c("table","script_desc",g);e.short_info.forEach(function(a){var e=f[a.prop]||a.value;if(e||!b){var h=c("tr","script_desc",a.prop,g),l=c("td","script_desc",a.prop,g+"dt"),k=c("td","script_desc",a.prop,g+"dd");l.textContent=a.label?a.label:"";k.textContent=e||d.getMessage("_not_set_");h.appendChild(l);h.appendChild(k);q.appendChild(h)}});
m.appendChild(q);var k=c("div","viewer_info viewer_info_multiple","info",g),t;b?t=m:(t=c("div","viewer_content","info_content",g),r=p("h4","action","heading",g),document.title=r.textContent=e.messages.heading,t.appendChild(r));var v=0;["errors","warnings","info"].forEach(function(a){var b=p("table",a,g+v);(e.messages[a]||[]).forEach(function(c){v++;var e=p("tr",a,g+v),f=p("td",a,g+"dt"+v),h=p("td",a,g+"dd"+v);if("info"==a)if(c.label&&c.value)f.textContent=c.label,h.textContent=c.value;else{var d=
'<i class="far fa-'+D.get("info")+'"></i>&nbsp;';y.RUNTIME.MOBILE||(f.innerHTML=d,d="");h.innerHTML=d+u.safeTagsReplace(c).replace(/\n/,"<br />")}else"warnings"==a?(d='<i class="far fa-'+D.get("critical")+'"></i>&nbsp;',y.RUNTIME.MOBILE||(f.innerHTML=d,d=""),h.innerHTML=d+u.safeTagsReplace(c).replace(/\n/,"<br />")):"errors"==a&&(d='<i class="far fa-'+D.get("error")+'"></i>&nbsp;',y.RUNTIME.MOBILE||(f.innerHTML=d,d=""),h.innerHTML=d+u.safeTagsReplace(c).replace(/\n/,"<br />"));e.appendChild(f);e.appendChild(h);
b.appendChild(e)});t.appendChild(b)});r=function(a,b,e,h){var l=p("table",a,g),k=0,m={};b.forEach(function(b){if(!(k>h||m[b])){m[b]=!0;var d=c("tr",a+"desc",b,g+k),f=c("td",a+"desc",b,g+k+"dt"),n=c("td",a+"desc",b,g+k+"dd");f.innerHTML=0==k?u.safeTagsReplace(e.label):"&nbsp;";n.innerHTML=k==h?'<span title="'+u.safeTagsReplace(e.warning)+'">...!</span>':u.safeTagsReplace(b);d.appendChild(f);d.appendChild(n);l.appendChild(d);k++}});if(f.options&&(b=f.options.override&&f.options.override["use_"+a])&&
b.length){b=c("tr",a+"desc","ovverride",g+k);var n=c("td",a+"desc","ovverride",g+k+"dt"),q=c("td",a+"desc","ovverride",g+k+"dd");n.innerHTML=0==k?u.safeTagsReplace(e.label):"&nbsp;";q.innerHTML=u.safeTagsReplace(" ("+d.getMessage("overwritten_by_user")+")");b.appendChild(n);b.appendChild(q);l.appendChild(b)}t.appendChild(l)};r("includes",(f.includes||[]).concat(f.matches||[]),{label:d.getMessage("Include_s__"),warning:d.getMessage("Attention_Can_not_display_all_includes_")},5);r("excludes",f.excludes||
[],{label:d.getMessage("Exclude_s__"),warning:d.getMessage("Attention_Can_not_display_all_excludes_")},3);l.appendChild(m);k.appendChild(t);n.appendChild(l);n.appendChild(k);l=c("div","section",g,"install_src");l.appendChild(n);a.install&&l.appendChild(a.install(e));a.editor&&l.appendChild(a.editor(e));h.appendChild(l)},Z=function(a){q(k.aid,"abort");window.setTimeout(function(){window.location=a+"#bypass=true"},10)},x=function(a){q(k.aid,"abort");window.setTimeout(function(){window.close()},3E3)},
U=function(a,b){q(k.aid,"unload");E&&(window.clearInterval(E),E=null);window.removeEventListener("unload",U)};window.addEventListener("unload",U);var V=function(){window.location.search||window.location.hash?(k=v.getUrlArgs(),k.aid?(q(k.aid,"preparat",{layout:!0}).done(function(a){a.ext&&a.ext.version&&(O=a.ext.version);a.i18n&&d.setLocale(a.i18n);if(a.options&&(a.options.statistics_enabled&&W.init("ask",O),a.options.layout_user_css)){var b=document.createElement("style");b.innerHTML=a.options.layout_user_css;
(document.head||document.body||document.documentElement||document).appendChild(b)}N=d.getMessage("Install");b=null;a.preparat&&("install"==a.type?b=function(){K({content:z(),preparat:a.preparat,install:aa,editor:X})}:"install_error"==a.type?b=function(){K({content:z(),preparat:a.preparat,install:ca},!0)}:"import"==a.type?b=function(){ha(z(),a.preparat)}:"permission"==a.type?b=function(){da(z(),a.preparat)}:"connect"==a.type&&(b=function(){fa(z(),a.preparat)}),E=window.setInterval(ia,3E3),b&&window.setTimeout(b,
1))}).fail(function(){x()}),C.wait(d.getMessage("Please_wait___"))):x()):window.onhashchange=function(){V()}},ia=function(){return q(k.aid,"ping",{bg:!0})},q=function(a,b,c){c=c||{};var h=B();try{var f={aid:a,method:b,layout:c.layout};c.data&&v.each(c.data,function(a,b){f[b]=c.data[b]});sendMessage({method:"askCom",data:f},function(a){c.bg||C.hide();t=a.options||t;c.layout&&G.applyTheme(a.layout);a.error?(a.please_close&&window.setTimeout(window.close,100),h.reject(a)):h.resolve(a)});c.bg||C.wait(d.getMessage("Please_wait___"))}catch(g){console.warn("sS: "+
g.message),h.reject()}return h.promise()},ea=function(a,b,c){try{sendMessage(v.assign({method:"buttonPress",name:a},b),function(a){c&&c(a)})}catch(d){console.log("button: "+d.message)}};rea.extension.onMessage.addListener(function(a,b,c){t=a.options||t;if("confirm"==a.method)v.confirm(a.msg,function(a){c({confirm:a})});else if("showMsg"==a.method)v.alert(a.msg),c({});else return!1;return!0});V()})});
