window.requestFileSystem||(window.requestFileSystem=window.webkitRequestFileSystem);
Registry.require("promise layout convert xmlhttprequest crcrc curtain tools layout/default/tabview layout/default/htmlutil helper statistics i18n syncinfo uri layout/default/layout_helper porter hinter cloud".split(" "),function(){var A=rea.FEATURES,C=Registry.get("promise"),w=Registry.get("crcrc").cr,f=Registry.get("crcrc").crc,Sa=Registry.get("layout/default/tabview"),q=Registry.get("layout/default/htmlutil"),mb=Registry.get("statistics"),ta=Registry.get("syncinfo"),ua=Registry.get("convert"),Ca=
Registry.get("tools"),t=Registry.get("curtain"),d=Registry.get("i18n"),u=Registry.get("helper"),va=Registry.get("uri"),da=Registry.get("porter"),Ta=window.Hinter=Registry.get("hinter"),Da=Registry.get("layout"),pa=Registry.get("layout/default/layout_helper"),z=pa.images,Ua=Registry.get("cloud"),Ea=Ca.cache,Fa;Da.render(function(){pa.addStyle();var wa={},v={},M=[],Ga="0.0.0",ba={},Va={},Z={},B=function(){var a,b,c;if(A.HTML5.LOCALSTORAGE&&(a=A.HTML5.LOCALSTORAGE.getItem("export_tm_settings"),b="true"===
a,a=A.HTML5.LOCALSTORAGE.getItem("export_externals"),a="false"!==a,c=A.HTML5.LOCALSTORAGE.getItem("cloud_config")))try{c=JSON.parse(ua.Base64.decode(c))}catch(e){}return{script_storage:!0,add_tm_settings:b,include_externals:a,cloud_config:c}}(),N,x={},P=function(a,b){var c,e;if((c=x[a])&&(e=c[b]))return e.apply(this,Array.prototype.slice.call(arguments,2))},ja=-1!=window.navigator.userAgent.indexOf("Mac")?"mac":"other";window.addEventListener("keydown",function(a){var b,c=!1;if("keydown"==a.type&&
!a.defaultPrevented){if(27==a.keyCode){b=N.getTabById("dashboard");if(!b.isSelected())return;if(a.target&&"text"==a.target.type){$(a.target).blur();return}x.multiselect.toggleRow(!1);c=!0}else if(("mac"!=ja&&39==a.keyCode||"mac"==ja&&40==a.keyCode)&&!a.ctrlKey&&a.altKey&&!a.shiftKey){if(b=N.getNextTab())b.select(),c=!0}else("mac"!=ja&&37==a.keyCode||"mac"==ja&&38==a.keyCode)&&!a.ctrlKey&&a.altKey&&!a.shiftKey&&(b=N.getPreviousTab())&&(b.select(),c=!0);if(c)return a.stopPropagation(),a.preventDefault(),
!1}},!0);window.addEventListener("keydown",function(a){var b,c,e=!1;if("keydown"==a.type&&!a.defaultPrevented){if(112==a.keyCode)(b=N.getTabById("help"))&&b.select(),e=!0;else if((38==a.keyCode||40==a.keyCode)&&a.shiftKey){b=N.getTabById("dashboard");if(!b.isSelected())return;if((b=Y.length&&Y[Y.length-1])&&(b=$(b))&&(e=!0,c=b.closest("tr"),c.length)){var d;38==a.keyCode?(c=c.prevAll("tr:visible:first"),d=!0):(c=c.nextAll("tr:visible:first"),d=!1);if(c.length){var m,k=c.find('input[name="scriptselectors"]');
-1!=Y.indexOf(k[0])?(Y.pop(),b.prop("checked",!1),b.removeClass("selected"),m=b):k.length&&(k.prop("checked",!0),k.addClass("selected"),Y.push(k[0]),void 0===Y.direction&&(Y.direction=d),m=k);m&&(q.isScrolledIntoView(c,{padding:100})||$("html, body").animate({scrollTop:d?c.offset().top-100-c.height():c.offset().top-$(window).height()+100+2*c.height()},0),x.multiselect.single_click())}}}else if(70==a.keyCode&&(a.ctrlKey||a.metaKey)){b=N.getTabById("dashboard");if(!b.isSelected())return;x.multiselect.toggleRow(!0,
!0);e=!0}else if(65==a.keyCode&&(a.ctrlKey||a.metaKey)){b=N.getTabById("dashboard");if(!b.isSelected()||a.target&&"text"==a.target.type)return;x.multiselect.un_selectAll(!0);e=!0}if(e)return a.stopPropagation(),a.preventDefault(),!1}},!1);var ca,ea=function(){var a={};return{store:function(b){b&&(a[b]=document.documentElement.scrollTop||document.body.scrollTop)},restore:function(b){void 0!==(b=a[b])&&(document.documentElement.scrollTop=document.body.scrollTop=b)}}}(),J=function(){var a={},b=function(){ca=
u.getUrlArgs(!0);Object.keys(a).forEach(function(b){b=a[b];d.is(b.main,b.sub)&&b.fn()})};b();var c;window.onhashchange=function(){c||b.apply(this,arguments)};var e=function(a){c=!0;a();c=!1},d={set:function(a){var c=d.get(),h;h="object"===typeof a?[a.main,a.sub].filter(function(a){return a}):arguments;if(c.main!==h[0]||c.sub!==h[1])!h[0]&&h[1]?d.setSub(h[1]):e(function(){window.location.hash="nav="+Array.prototype.join.call(h,"+");b()})},setSub:function(a){var c=d.get();c.sub!==a&&e(function(){window.location.hash=
"nav="+(c.main?c.main:"")+"+"+a;b()})},get:function(){var a=ca.nav?ca.nav.split("+"):[];return{main:a[0],sub:a[1]}},is:function(a,b){var c=d.get(),e=!b||c.sub===b;return(!a||c.main===a)&&e},isSub:function(a){return d.is(null,a)},registerListener:function(b,c,e){void 0===e&&(e=c,c=null);var m=[b,c].join("+");a[m]={main:b,sub:c,fn:e};d.is(b,c)&&e();return m},unregisterListener:function(b){delete a[b]},clear:function(){d.set("")}},m=d.get();M.push(function(){var a=N.getTabById(m.main);if(a)return a.select(!0);
if(m.main)(a=N.getTabById("dashboard"))&&a.select(!0),M.push(function(){window.setTimeout(function(){d.set(m)},1)});else window.onhashchange()});return d}();(function(){M.push(function(){v.statistics_enabled&&mb.init("opt",Ga)})})();var Ha=u.getDebouncer(1E3),Ia=function(){for(;M.length;)try{M.shift()()}catch(a){console.warn("doneListeners:",a)}},Ca=function(a,b){var c=w("input",a.name,a.id,"Save");c.inserted||(c.type="button",c.section=a,c.disabled=!0,c.value=d.getMessage("Save"),c.addEventListener("click",
function(){if(!b||!b.warning||qa(b.warning)){for(var a=$(this.section).find("input, select, textarea").toArray(),c=[],m=[],k=0;k<a.length;k++){var f=null,h=a[k],r=h.key;if(-1==m.indexOf(h)){if("textarea"==h.tagName.toLowerCase())if(h.named)h=document.getElementsByName(h.name),f=[],u.each(h,function(a){f.push({name:a.named_name,value:a.value});m.push(a)});else if(h.array)f=h.value.split("\n").map(function(a){return a.trim()}).filter(function(a){return a});else if(h.json){var p;try{f=(p=h.value)&&(p=
p.trim())?JSON.parse(p):null}catch(I){u.alert(d.getMessage("Unable_to_parse_0name0",h.name));return}}else f=h.value;else if("checkbox"==h.getAttribute("type"))f=h.checked;else if("select"==h.getAttribute("type")){var n=0;0<=h.selectedIndex&&h.selectedIndex<h.options.length&&(n=h.selectedIndex);f=h[n]?h[n].value:h.options[0].value}else"button"!=h.getAttribute("type")&&(f=h.value);r&&c.push(xa(r,f,b&&b.reload))}}b&&b.reload&&(t.wait(),C.when(c).done(function(){rea.page.reload()}))}},!1));return c},
pb=function(a){var b=function(a,b,c,d,e){var h,g=f("th","settingsth",a.name,a.id,b),m=f("a","settingsth_a",a.name,a.id,b+"_a");m.setAttribute("name","settingsth_a"+a.name);var r=f("a","settingsth_a_up",a.name,a.id,b+"_a_up");r.setAttribute("name","settingsth_a_up"+a.name);var k=f("a","settingsth_a_down",a.name,a.id,b+"_a_down");k.setAttribute("name","settingsth_a_down"+a.name);var p=function(){var b=document.getElementsByName("settingsth_a_up"+a.name),c=document.getElementsByName("settingsth_a_down"+
a.name);for(h=0;h<b.length;h++)b[h].style.display="none";for(h=0;h<c.length;h++)c[h].style.display="none";"up"==ka()?r.style.display="":k.style.display=""},E=function(){p()};b=function(){window.setTimeout(function(){ha()==d?Wa("down"==ka()?"up":"down"):Xa(d);Ya(E)},1)};g.inserted||(g.appendChild(m),g.appendChild(k),g.appendChild(r),m.addEventListener("click",b),r.addEventListener("click",b),k.addEventListener("click",b),m.textContent=c+" ",m.href="#",r.innerHTML="&#x25B4;",r.href="#",k.innerHTML=
"&#x25BE;",k.href="#");e&&!ha()?(Xa(d),Wa("up"),window.setTimeout(p,1)):d==ha()&&window.setTimeout(p,1);return g},c,e,g,m,k;m=w("tbody",a.name,a.id,"body");k=w("thead",a.name,a.id,"head");if(a.scriptTab){var l=nb(a),h=ob(a);c=w("table",a.name,a.id,"main");c.inserted||c.setAttribute("class","scripttable multiselect");var r=f("th","script_sel",a.name,a.id,"thead_sel");r.appendChild(l.selAllm);var p=f("th","left",a.name,a.id,"thead_multi_action");p.setAttribute("colspan",A.RUNTIME.MOBILE?3:11);p.appendChild(l.actionBox);
p.appendChild(h);h=f("th","right",a.name,a.id,"thead_multi_close");h.appendChild(l.close);g=f("tr","multiselectrow",a.name,a.id,"filler_multi");g.appendChild([r,p,h]);e=f("tr","scripttr multiselectreplaced",a.name,a.id,"filler");r=f("th","script_sel",a.name,a.id,"thead_sel");r.appendChild(l.selAll);var l=b(a,"thead_pos","#","pos"),p=b(a,"thead_en",d.getMessage("Enabled"),"enabled"),h=b(a,"thead_name",d.getMessage("Name"),"name",!0),n=f("th","settingsth",a.name,a.id,"thead_del");n.textContent=d.getMessage("Actions");
if(A.RUNTIME.MOBILE)u.each([r,l,p,h,n],function(a){e.appendChild(a)});else{var I=b(a,"thead_ver",d.getMessage("Version"),"ver"),F=f("th","settingsth ",a.name,a.id,"thead_type"),D=f("span","script_type",a.name,a.id,"thead_type_span");D.textContent=d.getMessage("Type");F.appendChild(D);var E=f("th","settingsth",a.name,a.id,"thead_sync");E.textContent="";D=b(a,"thead_sites",d.getMessage("Sites"),"sites");D.width="25%";var H=f("th","settingsth",a.name,a.id,"thead_features");H.textContent=d.getMessage("Features");
var y=b(a,"thead_homepage",d.getMessage("Homepage"),"homepage"),b=b(a,"thead_updated",d.getMessage("Last_updated"),"updated"),q=f("th","settingsth",a.name,a.id,"thead_sort");a=f("span","sorting",a.name,a.id,"thead_sort_span");a.textContent=d.getMessage("Sort");"pos"==ha()&&"up"==ka()||a.setAttribute("style","display: none;");q.appendChild(a);M.push(function(){v.sync_enabled&&(E.textContent=d.getMessage("Imported"))});u.each([r,l,p,h,I,F,E,D,H,y,b,q,n],function(a){e.appendChild(a)})}k.appendChild(g);
k.appendChild(e);e.inserted||(x.multiselect.checkScroll=function(){var a=$(k).is(":visible")&&$(g).is(":visible")&&$(window).scrollTop()>$(k).offset().top;$(g).toggleClass("multiscrolling",a)},$(window).scroll(x.multiselect.checkScroll))}else c=f("table","settingstable",a.name,a.id,"main");c.appendChild(k);c.appendChild(m);return{table:c,head:k,body:m}},Za=function(a,b,c,d){var g,m,k,l,h,r=[];l=function(a,b){if(c)if(c.save_button)$(a).on("change",function(){c.save_button.disabled=!1}),$(b).on("input propertychange",
function(){c.save_button.disabled=!1});else if(console.error("Section needs a save button!",c),Registry.isDevVersion("layout/default/layout_helper"))throw Error("Section needs a save button!");};if(b.divider)return null;b.image&&(b.image_id=z.get(b.image));if(b.checkbox)k=function(){var a=!0,b=this;b.warning&&(a=qa(b.warning),a||(b.checked=!b.checked));a&&xa(this.key,b.checked,b.reload).always(function(){b.reload&&rea.page.reload()})},c&&c.need_save&&(k=m=null),g=q.createCheckbox(b.name,b,k),r.push(g.elem),
c&&c.save_button&&l(null,g.input);else if(b.button)g=q.createButton(b.name,b,function(){var a=!0,b=this;b.warning&&(a=qa(b.warning));a&&qb(b.key,b.data,b.ignore).always(function(){b.reload&&rea.page.reload()})}),r.push(g);else if(b.named)g=q.createNamedSettings(b.name,b),r.push({element:g.elem,validation:g.label}),l(null,g.textareas);else if(b.input)g=q.createTextarea(b.name,b),r.push({element:g.elem,validation:g.label}),l(null,g.textarea);else if(b.text)g=q.createInput(b.name,b),r.push(g.elem),l(g.input);
else if(b.color)g=q.createColorChooser(b.name,b),r.push(g.elem),l(g.input);else if(b.password)g=q.createPassword(b.name,b),r.push(g.elem),l(g.input);else if(b.select)m=function(){var a=!0,b=this;b.warning&&(a=qa(b.warning),a||(b.value=b.oldvalue));a&&xa(b.key,q.getValue(b),b.reload).always(function(){b.reload&&rea.page.reload()})},c&&c.need_save&&(m=b.enabler?function(){var a=document.getElementsByName("enabled_by_"+this.key),b=(this.selectedIndex<this.options.length?this.options[this.selectedIndex]:
this.options[0]).getAttribute("enables"),c=b?JSON.parse(b):{};u.each(a,function(a){void 0===c[a.key]||c[a.key]?a.setAttribute("style",u.staticVars.visible):a.setAttribute("style",u.staticVars.invisible)})}:null),g=q.createDropDown(b.name,b,b.select,m,function(){var a=!0;this.selectedOptions.length&&this.selectedOptions[0].warning&&this.selectedOptions[0].value!==this.oldvalue&&(a=qa(this.selectedOptions[0].warning),a||(this.value=this.previousValue||this.oldvalue));this.previousValue=this.value}),
r.push(g.elem),c&&c.save_button&&l(g.select),a&&b.enabler&&function(){var a=m,b=g;M.push(function(){a.apply(b.select,[])})}();else if(b.url)k=w("a",b.name,b.id),k.href="#",k.url=b.url,k.newtab=b.newtab,k.inserted||(m=function(){za(this.url,this.newtab)},k.addEventListener("click",m)),k.textContent=b.name,r=Array(13),r[3]=k;else if(b.main_menu_item){k=w("div",b.name,b.id);k.textContent=b.name;l=pb(b);h=w("div",b.name,b.id,"tab_content");h.appendChild(l.table);var p=null,n=d.appendTab(b.id,k,h,function(a){J.is(b.id)||
ea.store(J.get().main);a.then(function(){p&&(wa.global?p():M.push(p));J.set(b.id);ea.restore(b.id);document.title=b.name})});J.registerListener(b.id,function(){n.select()});b.referrer&&(p=function(){p=null;t.wait();la({referrer:b.referrer},function(b){b.items&&b.items.forEach(function(b){Za(a,b,c,d)});Ia();t.hide()})});b.items&&Aa(l.body,b.items,null,d);!wa.global&&b.selected_default&&M.push(function(){d.getSelectedTab()||n.select()})}else b.sub_menu_item?(l=f("div","section",b.name,b.id,"section"),
k=f("div","section_head",b.name,b.id,"head"),h=f("table","section_content",b.name,b.id,"content"),k.textContent=b.name,l.appendChild(k),b.desc&&q.setHelp(b.desc,k,k,b),l.appendChild(h),b.need_save&&(b.save_button=Ca(h,b)),Aa(h,b.items,b,d),b.save_button&&h.appendChild(b.save_button),r.push(l)):b.userscript||b.nativeScript?(r=rb(b,a,d),b.userscript&&(Z[b.uuid]={dom:a,script:b}),a.setAttribute("class","scripttr"),b.nnew?a.setAttribute("style","display: none;"):Ha.is("script_refresh")||(M.push(function(){Ja.init(u.map(Z,
function(a){return a.script}));x.multiselect.single_click();Ya();wa.scripts=!0;Ha.clear()}),Ha.add("script_refresh")),b.nativeScript&&$("body").addClass("show_script_type")):b.version?(Ga=b.value,f("div","version","version","version").textContent="v"+Ga+" by Jan Biniok"):b.globalhint?Ka(u.copy(b.options,{onclick:b.options.info_url?function(){za(b.options.info_url,!0)}:null})):(k=w("span","",b.uuid||b.id+b.name),k.textContent=b.name,r=Array(13),r[3]=k);r.forEach(function(a){if(a){void 0!==b.level&&
(a.element||a).setAttribute("style",b.level>v.configMode?u.staticVars.invisible:u.staticVars.visible||"");if(b.hint){var c=w("span","",b.uuid||b.id+b.name,"hint");c.textContent=b.hint;a.appendChild(c)}b.validation&&sb(b,a.validation||a.element||a);b.width&&a.setAttribute("class","width-172-"+b.width)}});a&&(h=a.getAttribute("class"),k=" hide",!1===b.visible?h=(h||"")+k:h&&(h=h.replace(k,"")),a.setAttribute("class",h));return r},Aa=function(a,b,c,d){Object.keys(b).forEach(function(g){var m=b[g],k=
a?f("tr","settingstr",m.uuid||m.id+m.name,"pi"):null;(g=Za(k,m,c,d))&&g.length&&(a&&a.appendChild(k),u.each(g,function(a,b){var c=a,d="";"Object"===u.toType(a)&&(c=a.element,d=a.style||"");d=f("td",d+" settingstd","",m.uuid||m.id+m.name,b);a&&d.appendChild(c);k&&k.appendChild(d)}))})},qa=function(a){var b=a.msg||a;if(a.once){if(Va[b])return!0;Va[b]=!0}var b=confirm(b),c={};b&&a.ok?c=a.ok:!b&&a.cancel&&(c=a.cancel);if(a.ok||a.cancel)b=!0;c.url&&sendMessage({method:"newTab",url:c.url},function(){});
return b},sb=function(a,b){var c;a.validation&&(a.validation.url&&(c=function(){za(this.url,!0)}),c=q.createAfterIcon(a,c))&&(c.url=a.validation?a.validation.url:void 0,b.appendChild(c))},tb=function(a){var b=function(a){return a.url?{meta:{name:va.parse(a.url).pathname.split("/").pop(),url:a.url,sri:a.sri,ts:a.ts,mimetype:a.mimetype,modified:a.modified},source:a.data.content}:void 0},c=function(a){return a};return{source:a.code,meta:{name:a.name,uuid:a.uuid,modified:a.lastModified,file_url:a.file_url&&
a.file_url.trim()?a.file_url:void 0},storage:a.storage,options:a.options,settings:{enabled:a.enabled,position:a.position},resources:a.resources?a.resources.map(b).filter(c):[],requires:a.requires?a.requires.map(b).filter(c):[]}},La=function(a){var b=a.meta||{},c=a.settings||{},d=function(a){return{url:a.meta.url,sri:a.meta.sri,ts:a.meta.ts,mimetype:a.meta.mimetype,modified:a.meta.modified,content:a.source}};return{source:a.source,name:b.name,uuid:b.uuid,file_url:b.file_url,options:a.options,storage:a.storage,
lastModified:b.modified,enabled:c.enabled,position:c.position,resources:a.resources?a.resources.map(d):[],requires:a.requires?a.requires.map(d):[]}},Ba=function(a,b){var c=C(),d=[];ub(a,b).done(function(a){a.scripts.forEach(function(a){a.uuid&&a.userscript&&!a.system&&!a.nnew&&(a.code&&""!=a.code.trim()?d.push(tb(a)):console.log("options: Strange script: "+a.name))});c.resolve({scripts:d,global_settings:a.global_settings})}).fail(function(){c.reject()});return c.promise()},vb=function(a){var b,c,
e=w("div","help","help","tab_help_h"),g=e.textContent=d.getMessage("Help"),m=w("div","help","help","tab_help");return a.appendTab("help",e,m,function(a){J.is("help")||ea.store(J.get().main);a.then(function(){J.set("help");ea.restore("help");document.title=g;if(!c){t.wait();var a=f("div","section","help","help","ta"),e=f("div","section_head","help","help","head_ta"),r=f("div","section_content","help","help","content_ta");e.textContent=d.getMessage("Editor");a.appendChild([e,r]);var k=f("dl","dl-horizontal shortcuts",
"help","help","dl");r.appendChild(k);e=f("dt","keymapping","help","help","dt_mapping");b=f("dd","keymapping","help","help","dd_mapping");e.textContent=d.getMessage("Key_Mapping");b.textContent=v.editor_keyMap;k.appendChild([e,b]);if("vim"==v.editor_keyMap)b=f("dd","keymapping","help","help","dd_unsup"),b.textContent=d.getMessage("Please_check_the_0editor0_documentation_for_more_details_","VIM"),k.appendChild(b);else if("emacs"==v.editor_keyMap)b=f("dd","keymapping","help","help","dd_unsup"),b.textContent=
d.getMessage("Please_check_the_0editor0_documentation_for_more_details_","Emacs"),k.appendChild(b);else{var n=[];c={};var I=function(a){a=a.split(/-+/);var b=a.pop(),c=[],d="";-1!=(d=["up","down","left","right"].indexOf(b.toLowerCase()))&&c.push("#cursor");b.toLowerCase().match(/f[0-9]{1,2}/)&&c.push("#function");return c.length?c.join("-")+a.join("-")+d+b:("0000"+(100-Math.min(b.length,4))).slice(-4)+b+a.join("-")};[u.assign({Esc:"backOrClose"},"mac"!=ja?{"Alt-Left":"previousTab","Alt-Right":"nextTab"}:
{"Alt-Up":"previousTab","Alt-Down":"nextTab"}),CodeMirror.keyMap[v.editor_keyMap],"mac"!=ja?CodeMirror.keyMap.pcDefault:CodeMirror.keyMap.macDefault,CodeMirror.keyMap["default"]].forEach(function(a){Object.keys(a).forEach(function(b){c[b]||"fallthrough"==b||(n.push({name:b,fn:a[b].replace?a[b].replace(/([A-Z])/g," $1").replace(/ [A-Z]/g,function(a){return a.toLowerCase()}):a[b],sort:I(b)}),c[b]=!0)})});n.sort(function(a,b){return a.sort<b.sort?-1:a.sort>b.sort?1:0});n.forEach(function(a){var b=w("dt",
"help","help","dt_"+a.sort),c=w("dd","help","help","dd_"+a.sort);b.textContent=a.name;c.textContent=a.fn;k.appendChild([b,c])})}m.appendChild(a);t.hide()}})})},ra=function(){if(A.RUNTIME.FIREFOX)return window.saveAs=function(a,c){var d=URL.createObjectURL(a);wb(d,c,function(){URL.revokeObjectURL(d)})},C.Pledge();if(A.RUNTIME.EDGE&&window.navigator&&window.navigator.msSaveBlob)return window.saveAs=function(a,c){window.navigator.msSaveBlob(a,c)},C.Pledge();var a=C();Registry.vendor(["vendor/saveas/filesaver"],
function(){ra=C.Pledge;a.resolve()});return a.promise()},zb=function(a){var b={name:"utils",id:"utils"},c=w("div",b.name,b.id,"tab_util_h"),e=c.textContent=d.getMessage("Utilities"),g=w("div",b.name,b.id,"tab_util");a.appendTab(b.id,c,g,function(a){J.is(b.id)||ea.store(J.get().main);a.then(function(){J.set(b.id);ea.restore(b.id);document.title=e})}).show();a=f("div","tv_util",b.name,b.id,"tab_util_cont");var m=function(){Ua.init(function(a){var b=C(),c=rea.extension.connect("tabWatch");c.onMessage.addListener(function(a){(a=
a.tab)?b.notify(a):(c.disconnect(),b.resolve())});c.onDisconnect.addListener(function(){b.reject("auth_failed")});c.postMessage({method:"tabWatch",type:a.type,url:a.url});return{promise:b.promise(),close:function(){c.disconnect()}}});m=null},k={},l=function(a){var b,c;b=(c=B.cloud_config)?{url:c.url,basic_auth:ua.Base64.encode(c.user+":"+c.pass)}:{};return k[a]=k[a]||Ua[a](b)},h=function(){return Ba(null,{storage:B.script_storage,global_settings:B.add_tm_settings,externals:B.include_externals}).then(function(a){t.wait();
return da.zip.create(a.scripts,a.global_settings).progress(t.wait)})},r=function(a){var b=C(),c=new FileReader;c.onload=function(a){b.resolve(a.target.result)};c.readAsText(a);return b.promise()},p=function(a){for(var b=0,c;c=a[b];b++)da.zip.read(c).progress(t.wait).then(function(a){return Ma({scripts:u.map(a.scripts,function(a){return La(a)}),global_settings:a.global_settings},{reload:!0})}).done(function(a){a.err&&u.alert(a.err)}).fail(function(){u.alert(d.getMessage("Unable_to_parse_this_"))}).always(t.hide)},
n=q.createButton(b.name,b.id+"_i_ta",d.getMessage("Import"),function(){da.json.read(x.value).then(function(a){return Ma({scripts:u.map(a.scripts,function(a){return La(a)}),global_settings:a.global_settings},{reload:!0})}).done(function(a){a.err&&u.alert(a.err)}).fail(function(){u.alert(d.getMessage("Unable_to_parse_this_"))})}),I=q.createFileSelect(d.getMessage("Import"),{name:"zip",id:b.id},function(a){t.wait();return p(a)}),F=q.createFileSelect(d.getMessage("Import"),{name:"file",id:b.id},function(a){t.wait();
for(var b,c=0;b=a[c];c++)r(b).then(function(a){return da.json.read(a)}).then(function(a){return Ma({scripts:u.map(a.scripts,function(a){return La(a)}),global_settings:a.global_settings},{reload:!0})}).done(function(a){a.err&&u.alert(a.err)}).fail(function(){u.alert(d.getMessage("Unable_to_parse_this_"))}).always(t.hide)}),D=q.createButton(b.name,b.id+"_i_cloud",d.getMessage("Show_backups"),function(){t.wait();var a=T.select.value,b=T.select.selectedOptions[0].text;m&&m();l(a).list().progress(function(a){0<
a.total&&t.wait(b+": "+Math.floor(a.loaded/a.total*100)+"%")}).then(function(a){a=a.filter(function(a){return a.name.match(/\.zip$/)});return a.length?a:C.Breach("empty")}).then(function(b){var c=C(),e=$('<table class="nowrap file_select">');$('<thead><tr><th colspan="3">'+d.getMessage("Please_select_a_file")+":</th></tr></thead>").appendTo(e);b.sort(function(a,b){return a.modified-b.modified}).forEach(function(b){var h=$('<input class="button" type="button" value="'+d.getMessage("Import")+'">').click(function(){c.resolve(b);
t.hideDialog();t.wait()}),g=$('<input class="button" type="button" value="'+d.getMessage("Delete")+'">').click(function(){k.hide();l(a).delete(b)}),k=$("<tr><td>"+[q.safeTagsReplace(b.name),pa.formatBytes(b.size,2),(new Date(b.modified)).toLocaleString().replace((new Date).toLocaleDateString(),d.getMessage("Today"))].join("</td><td>")+"</td></tr>");$("<td>").append(h,g).appendTo(k);k.appendTo(e)});b=$('<input class="button" type="button" value="'+d.getMessage("Cancel")+'">').click(function(){c.reject("cancel");
t.hideDialog()});$("<tfoot>").append($("<tr>").append($('<td colspan="3">').append(b))).appendTo(e);t.hide();t.dialog(e[0]);return c.promise()}).then(function(c){return l(a).get(c).progress(function(a){0<a.total&&t.wait(b+": "+Math.floor(a.loaded/a.total*100)+"%")})}).then(function(a){return p([a])}).fail(function(a){var b;"empty"===a?b=d.getMessage("No_backups_found"):"cancel"!=a&&("auth_failed"==a?console.warn("cloud: Authentication failed"):b=d.getMessage("Error")+": "+a);b&&u.alert(b);t.hide()})}),
c=q.createButton(b.name,b.id+"_i_url",d.getMessage("Import"),function(){t.wait();return yb(V.value,{reload:!0}).fail(function(a){a=a.err?a.err:d.getMessage("Unable_to_parse_this_");u.alert(a)}).always(t.hide)}),E=q.createButton(b.name,b.id+"_e_ta",d.getMessage("Export"),function(){t.wait();Ba(null,{storage:B.script_storage,global_settings:B.add_tm_settings,externals:B.include_externals}).then(function(a){return da.json.create(a.scripts,a.global_settings)}).done(function(a){x.value=a}).always(t.hide)}),
H=q.createButton(b.name,b.id+"_e_file",d.getMessage("Export"),function(){t.wait();Ba(null,{storage:B.script_storage,global_settings:B.add_tm_settings,externals:B.include_externals}).then(function(a){return da.json.create(a.scripts,a.global_settings).then(function(a){return ra().done(function(){var b=new Blob([a],{type:"text/plain"});saveAs(b,u.safeFileName("tampermonkey-backup-"+A.RUNTIME.BROWSER+"-"+(new Date).toISOString()+".txt"))})})}).always(t.hide)}),y=q.createButton(b.name,b.id+"_e_zip",d.getMessage("Export"),
function(){return h().then(function(a){return ra().done(function(){saveAs(a,u.safeFileName("tampermonkey-backup-"+A.RUNTIME.BROWSER+"-"+(new Date).toISOString()+".zip"))})}).always(t.hide)}),ga=q.createButton(b.name,b.id+"_e_zip",d.getMessage("Export"),function(){var a=C(),b=T.select.value,c=T.select.selectedOptions[0].text,e=function(a){return h().then(function(d){t.wait(c+"...");m&&m();return l(b).put(a+".zip",d).progress(function(a){0<a.total&&t.wait(c+":"+Math.floor(a.loaded/a.total*100)+"%")})}).fail(function(a){u.alert(d.getMessage("Error")+
": "+a)}).always(t.hide)};u.prompt(d.getMessage("Name"),"backup-"+A.RUNTIME.BROWSER+"-"+(new Date).toISOString(),function(b){b?a.consume(e(b)):a.reject("aborted")});return a.promise()}),fa=q.createCheckbox(d.getMessage("Include_TM_settings"),{id:b.id+"_e_export_tm_settings",enabled:"true"},function(){B.add_tm_settings=this.checked;A.HTML5.LOCALSTORAGE&&A.HTML5.LOCALSTORAGE.setItem("export_tm_settings",B.add_tm_settings)});fa.elem.setAttribute("style","padding-left: 2px");fa.input.checked=B.add_tm_settings;
var O=q.createCheckbox(d.getMessage("Include_script_storage"),{id:b.id+"_e_export_storage",enabled:"true"},function(){B.script_storage=this.checked});O.elem.setAttribute("style","padding-left: 2px; display: inline");O.input.checked=B.script_storage;var G=q.createCheckbox(d.getMessage("Include_script_externals"),{id:b.id+"_e_export_externals",enabled:"true"},function(){B.include_externals=this.checked;A.HTML5.LOCALSTORAGE&&A.HTML5.LOCALSTORAGE.setItem("export_externals",B.include_externals)});G.elem.setAttribute("style",
"padding-left: 2px");G.input.checked=B.include_externals;var x=f("textarea","importta",b.name,b.id,"ta");x.setAttribute("spellcheck","false");var z=f("div","section",b.name,b.id,"ta"),S=f("div","section_head",b.name,b.id,"head_ta"),L=f("div","section_content",b.name,b.id,"content_ta");S.textContent=d.getMessage("General");L.appendChild(O.elem);L.appendChild(fa.elem);L.appendChild(G.elem);z.appendChild(S);z.appendChild(L);fa=f("div","section",b.name,b.id,"ta");O=f("div","section_head",b.name,b.id,
"head_ta");G=f("div","section_content",b.name,b.id,"content_ta");O.textContent=d.getMessage("TextArea");G.appendChild(E);G.appendChild(n);G.appendChild(x);fa.appendChild(O);fa.appendChild(G);n=f("div","section",b.name,b.id,"sb");E=f("div","section_head",b.name,b.id,"head_sb");O=f("div","section_content",b.name,b.id,"content_sb");E.textContent=d.getMessage("Zip");n.appendChild(E);n.appendChild(O);O.appendChild(y);O.appendChild(I.elem);var I=f("div","section",b.name,b.id,"sb"),y=f("div","section_head",
b.name,b.id,"head_sb"),E=f("div","section_content",b.name,b.id,"content_sb"),O=function(){$(U).toggle("webdav"===this.value)},T=q.createDropDown(d.getMessage("Type"),{id:"cloud_type",value:"edge"==A.RUNTIME.BROWSER?"onedrive":"drive"},[{name:"Google Drive",value:"drive"},"safari"==A.RUNTIME.BROWSER?null:{name:"Dropbox",value:"dropbox"},{name:"OneDrive",value:"onedrive"},{name:"WebDAV",value:"webdav"}].filter(function(a){return a}),O),L=function(a){return function(){k={};(B.cloud_config=B.cloud_config||
{})[a]=this.value;A.HTML5.LOCALSTORAGE&&A.HTML5.LOCALSTORAGE.setItem("cloud_config",ua.Base64.encode(JSON.stringify(B.cloud_config)))}},G=q.createInput(d.getMessage("URL"),{id:"select_cloud_url",uuid:b.uuid,value:(B.cloud_config?B.cloud_config.url:null)||""},L("url")),S=q.createInput(d.getMessage("Login"),{id:"select_cloud_username",uuid:b.uuid,value:(B.cloud_config?B.cloud_config.user:null)||""},L("user")),L=q.createInput(d.getMessage("Password"),{id:"select_cloud_password",uuid:b.uuid,password:!0,
value:(B.cloud_config?B.cloud_config.pass:null)||""},L("pass")),U=[G.elem,S.elem,L.elem];O.apply(T.select,[]);y.textContent=d.getMessage("Cloud");I.appendChild(y);I.appendChild(E);E.appendChild([T.elem].concat(U));E.appendChild(ga);E.appendChild(D);D=f("div","section",b.name,b.id,"fi");ga=f("div","section_head",b.name,b.id,"head_fi");y=f("div","section_content",b.name,b.id,"content_fi");ga.textContent=d.getMessage("File");D.appendChild(ga);D.appendChild(y);y.appendChild(H);y.appendChild(F.elem);var V=
f("input","updateurl_input",b.name,b.id,"url");V.setAttribute("type","text");V.setAttribute("spellcheck","false");F=f("div","section",b.name,b.id,"ur");H=f("div","section_head",b.name,b.id,"head_ur");ga=f("div","section_content",b.name,b.id,"content_ur");H.textContent=d.getMessage("URL");F.appendChild(H);F.appendChild(ga);ga.appendChild(V);ga.appendChild(c);a.appendChild(z);"undefined"!==typeof Blob&&a.appendChild(I);A.RUNTIME.CAN_SAVEAS_ZIP&&a.appendChild(n);"undefined"!==typeof Blob&&a.appendChild(D);
a.appendChild(fa);a.appendChild(F);u.each([fa],function(a){var b=a.getAttribute("class"),b=50>v.configMode?b+" hide":b.replace(" hide","");a.setAttribute("class",b)});g.appendChild(a)},Ab=function(){var a=document.getElementById("options"),b=f("div","content_wrapper","options","main");if(a){var c=a.parentNode;c.removeChild(a);c.appendChild(b);$(document.body).addClass("main")}var a=f("div","head_container","opt","head_container"),c=f("div","tv_container_fit","opt","tv_container"),d=w("a","head_link",
"heads","head_link");d.href="https://www.tampermonkey.net";d.target="_blank";var g=f("div","float","heads","head1"),m=f("img","banner","heads");m.src=rea.extension.getURL("images/icon128.png");var k=f("div","float head","heads","head2"),l=f("div","header_title","heads"),h=f("div","version","version","version");h.textContent=" by Jan Biniok";var r=w("div","search","box",""),p=f("div","footer","footer");l.innerHTML="Tampermonkey<sup>\u00ae</sup>";g.appendChild(m);k.appendChild(l);k.appendChild(h);d.appendChild(g);
d.appendChild(k);a.appendChild(d);a.appendChild(r);b.appendChild(a);b.appendChild(c);N=Sa.create("_main",c);N.setFooter(p);M.unshift(function(){zb(N);vb(N)});M.push(function(){void 0!==ca.contribute&&window.setTimeout(function(){ab("f")},100);wa.global=!0})},aa=function(a,b,c,e){void 0===e&&(e={});var g=b.item,m=g.uuid+(e.orig||"")+b.id,k=(e.orig?"orig_":"use_")+b.id,l=function(a){return"select_"+u.createUniqueId(a,g.uuid)+"_sel1"},h=f("div","cludes",a,m,"cb1"),r=w("span",a,m,"cb2");if(e.orig){var p=
"merge_"+b.id,p=q.createCheckbox(a,{id:p,uuid:g.uuid,enabled:g.options&&g.options.override&&g.options.override[p]?!0:!1},function(){if("checkbox"==this.type){var a={};a[this.key]=this.checked;ia(this.uuid,a)}});r.appendChild(p.elem)}else r.textContent=a;var n=f("select","cludes",k,g.uuid,"sel1");n.innerHTML="";n.setAttribute("size","6");n.setAttribute("multiple","true");for(k=0;k<c.length;k++)p=document.createElement("option"),p.value=p.text=c[k],n.appendChild(p);h.appendChild(r);g.desc&&q.setHelp(g.desc,
h,r,g);h.appendChild(n);var I=function(a){var b=[];a=a&&a.options;for(var c=0,d=a.length;c<d;c++)a[c].selected&&b.push(a[c]);return b},k=function(){var a=l("use_"+("excludes"==b.id?"includes":"excludes")),c=document.getElementById(a),a=I(n),d=!1,e="matches"==b.id;a.forEach(function(a){var b=e?"/"+va.getRegExpFromMatch(a.value)+"/":a.value;a&&!c.querySelector('option[value="'+b+'"]')&&(a=a.cloneNode(!0),e&&(a.value=b,a.textContent=b),c.appendChild(a),d=!0)});d&&D()},p=function(){var a=prompt(d.getMessage("Enter_the_new_rule"));
if(a){var b=document.createElement("option");b.value=b.text=a.trim();n.appendChild(b);D()}},r=function(){var a=n.options[n.selectedIndex];if(a){var b=prompt(d.getMessage("Enter_the_new_rule"),a.value);b&&(a.value=a.text=b.trim(),D())}};c=function(){var a=!1;I(n).forEach(function(b){b&&(b.parentNode.removeChild(b),a=!0)});a&&D()};var F=function(a){for(var b=[],c=0;c<a.options.length;c++)b.push(a.options[c].value);return b},D=function(){var a={includes:F(document.getElementById(l("use_includes"))),
matches:F(document.getElementById(l("use_matches"))),excludes:F(document.getElementById(l("use_excludes"))),connects:F(document.getElementById(l("use_connects"))),temp_connects:F(document.getElementById(l("use_temp_connects"))),blockers:F(document.getElementById(l("use_blockers")))};ia(g.uuid,a);return!0};e.other_name?(a=w("button",a,m,"btn1",!0),a.textContent=d.getMessage("Add_as_0clude0",e.other_name),a.addEventListener("click",k,!1),h.appendChild(a)):e.orig||(e=w("button",a,m,"btn2",!0),e.textContent=
d.getMessage("Add")+"...",e.addEventListener("click",p,!1),h.appendChild(e),e=w("button",a,m,"btn3",!0),e.textContent=d.getMessage("Edit")+"...",e.addEventListener("click",r,!1),h.appendChild(e),a=w("button",a,m,"btn4",!0),a.textContent=d.getMessage("Remove"),a.addEventListener("click",c,!1),h.appendChild(a));return{elem:h}},Oa=function(a){return a.homepage?a.homepage:a.namespace&&0==a.namespace.search(/https?:\/\//)?a.namespace:null};Ea.create("sites").setOptions({timeout:600,check_interval:300,
retimeout_on_get:!0}).init();var Ja=function(){var a={},b=function(a){return 7>a.toString().length?b("0"+a):a},c=function(a){if(a.includes||a.matches){for(var b={},c=[],d=a.includes.length?a.includes:a.matches,f=0;f<d.length;f++){var h=d[f];if(h){var r=Ea.items.sites.get(h),p=void 0!==r?r:q.getInfoFromUrl(h);void 0===r&&Ea.items.sites.set(h,p);p&&p.dom?b[p.dom]||(b[p.dom]=!0,c.push({include:h,info:p})):c.push({include:h})}else console.log("o: Warn: script '"+a.name+"' has invalid include (index: "+
f+")")}return c}};return{init:function(b){a={};b.forEach(function(b){(b=c(b))&&b.length&&b.forEach(function(b){b.info&&(a[b.info.dom]=(a[b.info.dom]||0)+1)})})},get:function(d){d=c(d);if(!d||!d.length)return b(0);d=u.map(d,function(b){return b.info?{score:1E3*a[b.info.dom]+b.info.dom.charCodeAt(0)||0,dom:b.info.dom}:{score:0,dom:""}}).sort(function(a,b){return b.score-a.score})[0];return b(d.score)+d.dom},topIcons:function(b,d){var m,k=[],l=c(b);if(!l||!l.length)return[];l=u.map(l,function(b){b.score=
b.info?a[b.info.dom]||0:0;return b}).sort(function(a,b){return b.score-a.score});u.each(l,function(a){var c=a.info;if(0==d--)return a=f("span","",b.uuid,"tbc"),a.textContent="...",k.push(a),!1;if(c){if("*"==c.tld)return m=q.createIcon(z.get("web"),"web",b.uuid,a.include,a.include),k.push(m),!1;var p="com",n="";"*"!=c.tld&&"tld"!=c.tld&&(p=c.tld);c.subdom.length&&(n=c.subdom.join(".")+".");p=(n+c.dom+"."+p).replace(/\*/g,"");n="http://"+p+"/";c=A.RUNTIME.CHROME?"chrome://favicon/"+n:null;p=0==n.search("http://userscripts.org/")||
0==n.search("http://userscripts.com/")?z.origin("uso"):"native"==v.favicon_service?n+"favicon.ico":"duckduckgo"==v.favicon_service?"https://icons.duckduckgo.com/ip2/"+encodeURIComponent(p)+".ico":"https://www.google.com/s2/favicons?domain="+encodeURIComponent(p);m=q.createFavicon([p,c,function(){return z.get("question_mark")}].filter(function(a){return a}),"favicon",b.uuid,a.include,a.include)}else m=q.createIcon(z.get("question_mark"),"favicon",b.uuid,a.include,a.include);k.push(m)});return k}}}(),
ha=function(){if(A.HTML5.LOCALSTORAGE)return A.HTML5.LOCALSTORAGE.getItem("sort_key")},ka=function(){if(A.HTML5.LOCALSTORAGE)return A.HTML5.LOCALSTORAGE.getItem("sort_sequence")},Xa=function(a){if(A.HTML5.LOCALSTORAGE)return A.HTML5.LOCALSTORAGE.setItem("sort_key",a)},Wa=function(a){if(A.HTML5.LOCALSTORAGE)return A.HTML5.LOCALSTORAGE.setItem("sort_sequence",a)},Ya=function(a){var b=function(a,c){return a.tagName==c?a:a.parentNode?b(a.parentNode,c):null},c="down"==ka(),e=null,g=[],f=0,k=Date.now();
Object.keys(Z).forEach(function(a){var c=Z[a];if(c)if(a=b(c.dom,"TR")){var p=b(a,"TBODY");e?p&&e!=p&&console.warn("options: different parents?!?!"):e=p;f++;var n,l;if(!(n=c.script.lastModified||c.script.lastUpdated)||(l=k-parseInt(n))&&isNaN(l))l=0;n=parseInt(c.script.version);isNaN(n)&&(n=0);g.push({tr:a,sites:Ja.get(c.script),enabled:c.script.enabled,position:c.script.position?c.script.position:1E3+f,name:d.getTranslation(c.script,"name").toLowerCase(),homepage:[c.script.origin?va.parse(c.script.origin.url).hostname:
"z",Oa(c.script)?va.parse(Oa(c.script)).hostname:"z"].join("_"),updated:l,version:n});a.inserted=!1;a.parentNode&&a.parentNode.removeChild(a)}else console.log("options: unable to sort script at pos "+c.pos);else console.warn("options: something went wrong!",a)});g=function(a){var b;b=function(a){return function(b,c){return b[a]-c[a]}};var d=function(a){return function(b,c){return b[a]<c[a]?-1:b[a]>c[a]?1:0}},e=function(a,b){return function(c,d){var e=(b^c[a]?"a":"b")+c.name,g=(b^d[a]?"a":"b")+d.name;
return e<g?-1:e>g?1:0}},g=ha();"pos"==g?b=b("position"):"enabled"==g?(b=e("enabled",c),c=null):b="ver"==g?b("version"):"updated"==g?b("updated"):d(g);a.sort(b);return a}(g);c&&(g=g.reverse());for(var l=0;l<f;l++)e.appendChild(g[l].tr);$(".sorting").each(function(a,b){var c=$(b),d="pos"==ha()&&"up"==ka();c[d?"fadeIn":"fadeOut"]()});a&&a()},Eb=function(a,b,c,e,g){c=w("div",b.uuid,"script_tab_head");var m=c.inserted,k=f("table","noborder p100100 heading",b.uuid,"h_table"),l=f("tr","",b.uuid,"h_tr1"),
h=f("td","nameNicon64",b.uuid,"h_td1"),r=f("td","",b.uuid,"h_td2");k.appendChild(l);l.appendChild(h);l.appendChild(r);r.setAttribute("style","width: 99%");var l=w("img",b.uuid,"heading_icon"),p=b.icon64?b.icon64:b.icon;l.src=p;var n=f("div","nameNname64",b.uuid,"heading_name");n.textContent=d.getTranslation(b,"name");p&&h.appendChild(l);r.appendChild(n);h=f("div","author",b.uuid,"author");b.author?h.textContent="by "+b.author:b.copyright&&(h.innerHTML="&copy; ",h.textContent+=b.copyright);r.appendChild(h);
r=f("table","noborder p100100",b.uuid,"table");h=f("tr","script_tab_head",b.uuid,"tr1");l=f("tr","details",b.uuid,"tr2");p=f("td","",b.uuid,"td1");n=f("td","",b.uuid,"td2");c.appendChild(k);p.appendChild(c);h.appendChild(p);l.appendChild(n);r.appendChild(h);r.appendChild(l);e.appendChild(r);var q=Sa.create("_details"+b.uuid,n,{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_close",tv_tab:"tv_tab tv_tab_alt",tv_content:"tv_content tv_content_alt"},!0),F=bb(b,q,{do_close:g,set_tab_class:function(b,c){a.toggleClass(b,c)},navid:"editor",treeid:"source"}),D=b.nnew||b.system?{}:Bb(b,q),E=b.nnew||b.system||!b.storage_key_count||
80>v.configMode?{}:Cb(b,q),H=b.nnew||b.system||!b.requires.length&&!b.resources.length?{}:Db(b,q);if(m)return ba["tab"+b.uuid];var y=function(){var a;return(a=q.getSelectedTab())&&a.isCloseable()?H.getEditor():F.getEditor()},t=function(b){var c=!1;if("keydown"==b.type&&a.isSelected()&&!b.defaultPrevented){if(27==b.keyCode){if(!v.editor_enabled||"vim"!=v.editor_keyMap){var d;(d=q.getSelectedTab())&&d.isCloseable()?d.close():window.setTimeout(g,1);c=!0}}else if(v.editor_enabled){var e={save:!0,find:!0,
findNext:!0,findPrev:!0,replace:!0,replaceAll:!0},h=y();d=CodeMirror.keyName(b);h&&!h.hasFocus()&&"handled"==CodeMirror.lookupKey(d,h.getOption("keyMap"),function(a){if(e[a])return h.execCommand(a),!0})&&(c=!0)}else 83==b.keyCode&&(b.ctrlKey||b.metaKey)&&(d=y())&&(d.save(),c=!0);if(c)return b.stopPropagation(),b.preventDefault(),!1}};e={onShow:function(){u.each([D,F,E,H],function(a){if(a.onShow)a.onShow()});window.addEventListener("keydown",t,!1)},onClose:function(a){var b;u.each([D,F,E,H],function(c){if(c.onClose&&
c.onClose(a))return b=!0,!1});b||window.removeEventListener("keydown",t,!1);return b},onSelect:function(a){J.is(b.uuid)||ea.store(J.get().main);a.then(function(){if(b.uuid){var a=J.get().sub,c=q.getTabById(a);J.set(b.uuid,(c?a:null)||"editor");document.title=d.getTranslation(b,"name");ea.restore(b.uuid)}});u.each([D,F,H],function(b){if(b.onSelect)b.onSelect(a)})}};return ba["tab"+b.uuid]=e},Bb=function(a,b){var c=w("div",a.uuid,"script_setting_h"),e=w("div",a.uuid,"script_settings_c");c.textContent=
d.getMessage("Settings");var g=function(){var a={};if("checkbox"==this.type)a[this.key]=!!this.checked,ia(this.uuid,a);else if("button"==this.type)a[this.key]=!this.oldvalue,ia(this.uuid,a);else if("text"==this.type||"textarea"==this.type||"select-one"==this.type){var b=q.getValue(this);a[this.key]=b;ia(this.uuid,a)}},m=q.createPosition(d.getMessage("Position_")+": ",{id:"position",uuid:a.uuid,name:"pos",pos:a.position,posof:a.positionof},g),k=q.createDropDown(d.getMessage("Run_at"),{id:"run_at",
uuid:a.uuid,name:"run-at",value:a.run_at},[{name:"document-start",value:"document-start"},{name:"document-body",value:"document-body"},{name:"document-end",value:"document-end"},{name:"document-idle",value:"document-idle"},{name:"context-menu",value:"context-menu"},{name:d.getMessage("Default"),value:null}],g),l=q.createDropDown(d.getMessage("No_frames"),{id:"noframes",uuid:a.uuid,name:"no_frames",value:a.noframes},[{name:d.getMessage("Yes"),value:!0},{name:d.getMessage("No"),value:!1},{name:d.getMessage("Default"),
value:null}],g),h=q.createCheckbox(d.getMessage("Check_for_Updates"),{id:"check_for_updates",uuid:a.uuid,name:"upd",enabled:a.check_for_updates}),r=q.createInput(d.getMessage("Update_URL_"),{id:"file_url",uuid:a.uuid,name:"uu",value:a.file_url});r.input.setAttribute("class","updateurl_input");r.elem.setAttribute("class","updateurl");a.is_external&&r.input.setAttribute("readonly","true");var p=function(b){return(a.options&&a.options.override?a.options.override[b]:null)||[]},n=aa(d.getMessage("Original_includes"),
{id:"includes",item:a},p("orig_includes"),{orig:!0,other_name:d.getMessage("User_excludes")}),I=aa(d.getMessage("Original_matches"),{id:"matches",item:a},p("orig_matches"),{orig:!0,other_name:d.getMessage("User_excludes")}),F=aa(d.getMessage("Original_excludes"),{id:"excludes",item:a},p("orig_excludes"),{orig:!0,other_name:d.getMessage("User_includes")}),D=f("div","clear",a.uuid,"clear"),E=aa(d.getMessage("User_includes"),{id:"includes",item:a},p("use_includes")),H=aa(d.getMessage("User_matches"),
{id:"matches",item:a},p("use_matches")),y=aa(d.getMessage("User_excludes"),{id:"excludes",item:a},p("use_excludes")),t=aa(d.getMessage("Original_domain_whitelist"),{id:"connects",item:a},a.connects,{orig:!0}),u=aa(d.getMessage("Temporary_domain_whitelist"),{id:"temp_connects",item:a},a.temp_connects),v=aa(d.getMessage("User_domain_whitelist"),{id:"connects",item:a},p("use_connects")),p=aa(d.getMessage("User_domain_blacklist"),{id:"blockers",item:a},p("use_blockers")),x=q.createCheckbox(d.getMessage("Apply_compatibility_options_to_required_script_too"),
{id:"compatopts_for_requires",uuid:a.uuid,name:"",enabled:a.compatopts_for_requires},g),z=q.createCheckbox(d.getMessage("Fix_wrappedJSObject_property_access"),{id:"compat_wrappedjsobject",uuid:a.uuid,name:"",enabled:a.compat_wrappedjsobject},g),A=q.createCheckbox(d.getMessage("Convert_CDATA_sections_into_a_chrome_compatible_format"),{id:"compat_metadata",uuid:a.uuid,name:"",enabled:a.compat_metadata},g),C=q.createCheckbox(d.getMessage("Replace_for_each_statements"),{id:"compat_foreach",uuid:a.uuid,
name:"",enabled:a.compat_foreach},g),L=q.createCheckbox(d.getMessage("Fix_for_var_in_statements"),{id:"compat_forvarin",uuid:a.uuid,name:"",enabled:a.compat_forvarin},g),T=q.createCheckbox(d.getMessage("Convert_Array_Assignements"),{id:"compat_arrayleft",uuid:a.uuid,name:"",enabled:a.compat_arrayleft},g),U=q.createCheckbox(d.getMessage("Add_toSource_function_to_Object_Prototype"),{id:"compat_prototypes",uuid:a.uuid,name:"",enabled:a.compat_prototypes},g),V=[x,z,A,C,L,T,U],x=f("div","section",a.uuid,
"ta_opt"),A=f("div","section_head",a.uuid,"head_ta_opt"),z=f("div","section_content",a.uuid,"content_ta_opt");A.textContent=d.getMessage("Settings");x.appendChild(A);x.appendChild(z);A=f("div","section",a.uuid,"ta_upd");L=f("div","section_head",a.uuid,"head_ta_upd");C=f("div","section_content",a.uuid,"content_ta_upd");L.textContent=d.getMessage("Updates");A.appendChild(L);A.appendChild(C);L=f("div","section",a.uuid,"ta_cludes");U=f("div","section_head",a.uuid,"head_ta_cludes");T=f("div","section_content",
a.uuid,"content_ta_cludes");U.textContent=d.getMessage("Includes_Excludes");L.appendChild(U);L.appendChild(T);var U=f("div","section",a.uuid,"ta_security"),B=f("div","section_head",a.uuid,"head_ta_security"),M=f("div","section_content",a.uuid,"content_ta_security");B.textContent=d.getMessage("XHR_Security");U.appendChild(B);U.appendChild(M);var B=f("div","section",a.uuid,"ta_compat"),P=f("div","section_head",a.uuid,"head_ta_compat"),N=f("div","section_content",a.uuid,"content_ta_compat");P.textContent=
d.getMessage("GM_compat_options_");B.appendChild(P);B.appendChild(N);z.appendChild(m);z.appendChild(k.elem);z.appendChild(l.elem);m=q.createButton("save_update_button",a.uuid,d.getMessage("Save"),function(){g.apply(h.input,[]);a.is_external||g.apply(r.input,[])});C.appendChild([h.elem,r.elem,m]);T.appendChild([n.elem,I.elem,F.elem,D,E.elem,H.elem,y.elem]);M.appendChild([t.elem,u.elem,v.elem,p.elem]);e.appendChild([x,A,L,U]);for(n=0;n<V.length;n++)N.appendChild(V[n].elem);a.awareOfChrome&&Object.keys(V).forEach(function(a){V[a].input.setAttribute("disabled",
"disabled");V[a].elem.setAttribute("title",d.getMessage("This_script_runs_in_Chrome_mode"))});e.appendChild(B);var Na=q.createTextarea(null,{name:"",uuid:a.uuid,id:"comment",value:a.options.comment});Na.elem.setAttribute("class","script_setting_wrapper");n=w("div",a.uuid,"save");I=q.createButton("save_button",a.uuid,d.getMessage("Save"),function(){g.apply(Na.textarea,[])});n.appendChild(I);I=f("div","section",a.uuid,"ta_comment");F=f("div","section_head",a.uuid,"head_ta_comment");D=f("div","section_content",
a.uuid,"content_ta_comment");F.textContent=d.getMessage("Comment");I.appendChild(F);I.appendChild(D);D.appendChild(Na.elem);D.appendChild(n);e.appendChild(I);n=f("div","section",a.uuid,"ta_det");I=f("div","section_head",a.uuid,"head_ta_det");F=f("div","section_content",a.uuid,"content_ta_det");I.textContent=d.getMessage("Details");n.appendChild(I);n.appendChild(F);I.textContent=d.getMessage("Details");var $a=f("table","script_details",a.uuid,"script_details");[{label:d.getMessage("Size"),value:pa.formatBytes((a.code?
a.code:a).length,2)},{label:d.getMessage("UUID"),value:a.uuid}].forEach(function(b){var c=f("tr","external_desc",a.uuid,b.label,"tr"),d=f("td","external_desc",a.uuid,b.label,"td1"),e=f("td","",a.uuid,b.label,"td2");d.textContent=b.label;e.textContent=b.value;c.appendChild(d);c.appendChild(e);$a.appendChild(c)});F.appendChild($a);e.appendChild(n);var xb=b.appendTab("settings",c,e,function(a){a.then(function(){J.setSub("settings")})});J.registerListener(a.uuid,"settings",function(){xb.select()});return{}},
cb=function(a,b,c,e){var g=f("table","externals",a.uuid,"outer_req2html",b,!0),m=0,k=[{label:d.getMessage("URL"),prop:"display_url"},{label:d.getMessage("Size"),prop:"data",fn:function(a){var b="?";a&&(void 0!==a.length?b=a.length:void 0!==a.content&&(b=a.content.length));return pa.formatBytes(b,2)}},{label:d.getMessage("MIME_Type"),prop:"mimetype"},{label:d.getMessage("Subresource_Integrity"),prop:"sri",fn:function(a){return a?a.type+"="+a.value:d.getMessage("_not_set_")}},{label:d.getMessage("Last_updated"),
prop:"ts",fn:function(a){return a?(new Date(a)).toString():null}}];k.push({label:d.getMessage("User_modified"),prop:"modified",klass:"validation",title:d.getMessage("This_external_resource_will_not_auto_update__Please_delete_it_in_order_to_enable_updates_again_"),icon:z.get("info"),fn:function(a){return a?d.getMessage("Yes"):null}});a[b].forEach(function(h){var p=m+u.createUniqueId(h.url)+b;k.forEach(function(b){var c,d=f("tr","",a.uuid,b.prop,"tr"+p),e=f("td","external_label",a.uuid,b.prop,"td1"+
p),k=f("td","external_desc",a.uuid,b.prop,"td2"+p);e.textContent=b.label;k.textContent=c=(b.fn?b.fn:function(a){return a})(h[b.prop]);null!==c&&(b.klass&&$(k).addClass(b.klass),b.title&&k.setAttribute("title",b.title),b.icon&&(c=f("span","validation",a.uuid,"validation","span"+p),c.appendChild(q.createIcon(b.icon+" red","warning",a.uuid,p+"no_require_update_warning")),k.appendChild(c)),d.appendChild(e),d.appendChild(k),g.appendChild(d))});var n=f("tr","external_desc_buttons",a.uuid,h.url,"tr"+p),
l=f("td","",a.uuid,"buttons","td"+p);n.appendChild(l);g.appendChild(n);if(h.ts){if("requires"==b||h.editable){var n=w("span",a.uuid,"edit_external"+p),F=q.createImageTextButton(a.uuid,"edit_external"+p,d.getMessage("Edit"),"edit",function(){Fb(c,a.uuid,h,e)});n.appendChild(F);l.appendChild(n)}var n=w("span",a.uuid,"delete_external"+p),D=q.createImageTextButton(a.uuid,"delete_external"+p,d.getMessage("Delete"),"delete",function(){Gb(a.uuid,h.url);D.parentNode&&D.parentNode.removeChild(D)});n.appendChild(D);
l.appendChild(n)}m++});if(!m){var l=f("tr","script_desc",a.uuid,m,"tr"),h=f("td","script_desc",a.uuid,m,"td1");h.textContent=d.getMessage("No_entry_found");l.appendChild(h);g.appendChild(l)}return g},Fb=function(a,b,c,e){var g="externals-"+b+"-"+c.url;x[g]={};var f=Hb({uuid:g,script_uuid:b,mimetype:c.mimetype,name:d.getMessage("Externals")+" - "+c.url,file_url:c.url,referrer:"options.scripts.userscripts"},a,function(){e(f.getEditor())},function(){delete ba["tab"+g];delete ba["editor"+g];delete x[g]});
f.show()},Db=function(a,b){var c,e=function(a){c=a},g=w("div","",a.uuid,"script_external_h");g.textContent=d.getMessage("Externals");var m=w("div","",a.uuid,"script_externals_c"),k=f("div","section",a.uuid,"ta_requires"),l=f("div","section_head",a.uuid,"head_ta_requires"),h=f("div","section_content",a.uuid,"content_ta_requires");l.textContent=d.getMessage("Requires");k.appendChild(l);k.appendChild(h);h.appendChild(cb(a,"requires",b,e));var l=f("div","section",a.uuid,"ta_resources"),h=f("div","section_head",
a.uuid,"head_ta_resources"),r=f("div","section_content",a.uuid,"content_ta_resources");h.textContent=d.getMessage("Resources");l.appendChild(h);l.appendChild(r);r.appendChild(cb(a,"resources",b,e));m.appendChild(k);m.appendChild(l);var p=b.appendTab("externals",g,m,function(a){a.then(function(){J.setSub("externals")})});J.registerListener(a.uuid,"externals",function(){p.select()});return{getEditor:function(){return c}}},Cb=function(a,b){var c=function(a,b){if("string"===typeof a){var c=a[0];a=a.substr(1);
switch(c){case "b":return"true"===a;case "n":return Number(a);case "o":try{return JSON.parse(a)}catch(d){console.log("values: parseValueFromStorage: "+d)}return b;default:return a}}else return b},e=w("div","",a.uuid,"script_storage_h");e.textContent=d.getMessage("Storage");var g=w("div","",a.uuid,"script_storages_c"),m=f("div","section",a.uuid,"ta_storage"),k=f("div","section_head",a.uuid,"head_ta_storage"),l=f("div","section_content",a.uuid,"content_ta_storage");k.textContent=d.getMessage("Storage");
m.appendChild(k);m.appendChild(l);var h=f("textarea","storageta",a.uuid,"storage");h.setAttribute("wrap","off");h.setAttribute("wrap","off");h.setAttribute("spellcheck","false");k=q.createButton("storage_save_button",a.uuid,d.getMessage("Save"),function(){var b=null;try{b=JSON.parse(h.value)}catch(c){u.alert(d.getMessage("Unable_to_parse_this_"));return}var e=Object.keys(b),g=Object.keys(a.storage);e.concat(g).filter(function(a,b,c){return c.lastIndexOf(a)===b}).forEach(function(c){if(-1==e.indexOf(c))db(a.uuid,
c);else if(-1==g.indexOf(c)||b[c]!==a.storage[c]){var d=db,h=a.uuid,k;a:{k=b[c];var f=(typeof k)[0];switch(f){case "o":try{k=f+JSON.stringify(k)}catch(m){console.log(m);k=void 0;break a}break;default:k=f+k}}d(h,c,k)}})});l.appendChild(h);l.appendChild(k);g.appendChild(m);var r=b.appendTab("storage",e,g,function(a){a.then(function(){J.setSub("storage")})});J.registerListener(a.uuid,"storage",function(){(function(){if(a.referrer&&void 0===a.storage){var b=C();la({referrer:a.referrer+".storage",uuid:a.uuid},
function(a){if(a.items){var d={},e=a.items[0];Object.keys(e).forEach(function(a){d[a]=c(e[a])});b.resolve(d)}else b.reject();t.hide()});return b.promise()}return C.Pledge(a.storage)})().done(function(b){h.value=h.value||JSON.stringify(b,null,4);a.storage=b;h.removeAttribute("disabled")}).fail(function(){h.setAttribute("disabled",!0)});r.select()});return{}},Hb=function(a,b,c,d){var g;a.is_external=!0;var f=function(){g&&!k.onClose()&&(d(),g&&g.remove(),g=null)},k=bb(a,b,{tab_name:a.name,navid:a.uuid,
treeid:"external",mimetype:a.mimetype,tree_opts:{url:a.file_url,uuid:a.script_uuid},do_close:function(){window.setTimeout(f,100)},on_tab_close:f,on_tab_select:c,on_editor_load:c});g=k.getTab();k.show=function(){k.onShow();g.select()};return k},bb=function(a,b,c){var e=f("tr","editor_container p100100",a.uuid,"container"),g=c.mimetype||"text/javascript",m=!g||/(application|text)\/(?:x-)?(?:java|ecma)script/.test(g);if(!a.nnew&&P(a.uuid,"lastI"))return ba["editor"+a.uuid]||{};a.nnew&&(a.code=v.script_templates[0].value.replace("<$URL$>",
ca.url?ua.Base64.decode(ca.url):"http://*/*"));var k=w("div",a.uuid,"script_editor_h"),l=k.inserted,h=w("div",a.uuid,"script_editor_c"),r=f("tr","editormenubar",a.uuid,"container_menu"),p=f("tr","editorbuttonbar",a.uuid,"container_button_menu"),n=f("table","editor_container_o p100100 noborder",a.uuid,"container_o");n.appendChild(p);n.appendChild(r);n.appendChild(e);h.appendChild(n);var I=function(){var b=!1;e.editor&&(b=v.editor_enabled?b|(e.editor.changed&&e.editor.mirror.historySize().undo):e.editor.value!=
a.code);return b},F=function(){CodeMirror.commands.trimTrailingSpacesIfEnabled(e.editor.mirror);P(a.uuid,"saveEm")},D=function(a,b,d){c.do_close&&c.do_close(b,d)},n=function(){confirm(d.getMessage("Really_factory_reset_this_script_"))&&x[a.uuid].fullReset(function(a){a.cleaned&&D(null,!0,!1)})},E=function(a){e.editor.changed!=a&&(c.set_tab_class&&c.set_tab_class("modified",a),ya.toggleClass("modified",a));e.editor.changed=a},H=function(){window.setTimeout(function(){var a;v.editor_enabled&&(a=e.editor)&&
(t.wait(),window.setTimeout(function(){(function(){var b=a.mirror.performLint(!0);return b&&b.then?b:C.Pledge(b)})().then(function(){var b=a.mirror.state.lint?a.mirror.state.lint.marked:null;if(b&&b.length){1===b.length?eb(d.getMessage("One_error_or_hint_was_found_")):eb(d.getMessage("0count0_errors_or_hints_were_found_",b.length));for(var c,e=0;c=b[e];e++){var g,h;void 0!==c.line&&void 0!==c.column?(g=c.line,h=c.column):c.lines&&c.lines.length&&(c=c.lines[0],g=c.lineNo()+1,h=c.markedSpans&&c.markedSpans.length?
c.markedSpans[0].from+1:1);if(g&&h){a.mirror.setCursor(g-1,h-1);a.mirror.focus();break}}}else fb(d.getMessage("No_syntax_errors_were_found_"));t.hide()})},100))},1)},y=f("td","",a.uuid,"editor_buttonmenu_td");p.appendChild(y);var A=f("ul","editormenu",a.uuid,"editormenu"),p=f("td","",a.uuid,"editormenu_td");p.appendChild(A);var B,O,G=function(a,b){var c,d;a&&(c=$(a),d=b?c.hasClass("visible"):!1);$("ul.editormenu .submenu").removeClass("visible");a?(c.toggleClass("visible",!d),O=d?null:a):O=null;a&&
d||(B=function(a){var b;B&&(b=$(a.target))&&!b.closest(".editormenu").length&&(G(),document.body.removeEventListener("click",B),B=null)},document.body.addEventListener("click",B))},K=function(b,c){var d=f("li","entry",a.uuid,b,"editormenuentry",!0),e=w("label",a.uuid,b,"editormenulabel_id");e.textContent=c;var g=f("table","submenu noborder",a.uuid,"editormenucontent"+b);d.appendChild([e,g]);d.addEventListener("click",function(a){$(a.target).closest(".entry").hasClass("list")||G(g,!0)});d.addEventListener("mousemove",
function(){O&&O!=this&&G(g)});return{elem:d,content:g}},M=function(a){return function(){e.editor.mirror.focus();e.editor.mirror.execCommand(a)}},S={file:{text:d.getMessage("File"),entries:[{text:d.getMessage("Save"),command:"save",image:z.get("filesave"),cb:F},{text:d.getMessage("Save_to_disk"),command:"save_to_disk",image:z.get("save_to_disk"),cb:function(){P(a.uuid,"saveToDisk")}},{type:"sep"},{command:"cancel",text:d.getMessage("Editor_reset"),image:z.get("editor_cancel"),cb:function(){confirm(d.getMessage("Really_reset_all_changes_"))&&
e.editor&&(v.editor_enabled?(e.editor.mirror.setValue(a.code),E(!1)):e.editor.value=a.code)}},{type:"sep"},{text:d.getMessage("Close"),command:"close",image:z.get("exit"),cb:D}]},edit:{text:d.getMessage("Edit"),entries:[{text:d.getMessage("Undo"),command:"undo"},{text:d.getMessage("Redo"),command:"redo"},{type:"sep"},{text:d.getMessage("Cut"),command:"cut"},{text:d.getMessage("Copy"),command:"copy"},{text:d.getMessage("Paste"),command:"paste"},{text:d.getMessage("Select_All"),command:"selectAll"},
{type:"sep"},{text:d.getMessage("Toggle_Comment"),command:"toggleComment"},{text:d.getMessage("Toggle_Comment_Indented"),command:"toggleCommentIndented"},{text:d.getMessage("Toggle_Block_Comment"),command:"toggleBlockComment",modes:["js"]},{type:"sep"},{id:"edit_lines",text:d.getMessage("Lines"),modes:["js"],entries:[{text:d.getMessage("Indent"),command:"intelligentTab"},{text:d.getMessage("Indent_Less"),command:"indentLess"},{text:d.getMessage("Indent_More"),command:"indentMore"},{text:d.getMessage("Auto_Indent_all"),
command:"reindentall"},{type:"sep"},{text:d.getMessage("Move_Line_Up"),command:"swapLineUp"},{text:d.getMessage("Move_Line_Down"),command:"swapLineDown"},{text:d.getMessage("Duplicate_Lines"),command:"duplicateLine"},{text:d.getMessage("Delete_Line"),command:"deleteLine"},{text:d.getMessage("Join_Lines"),command:"joinLines"},{type:"sep"},{text:d.getMessage("Insert_Line_Before"),command:"insertLineBefore"},{text:d.getMessage("Insert_Line_After"),command:"insertLineAfter"}]},{id:"edit_text",text:d.getMessage("Text"),
entries:[{text:d.getMessage("Upper_Case"),command:"upcaseAtCursor"},{text:d.getMessage("Lower_Case"),command:"downcaseAtCursor"},{type:"sep"},{text:d.getMessage("Delete_Line_Left"),command:"delLineLeft"},{text:d.getMessage("Delete_Line_Right"),command:"delLineRight"},{text:d.getMessage("Delete_to_Previous_Word_Boundary"),command:"delGroupBefore"},{text:d.getMessage("Delete_to_Next_Word_Boundary"),command:"delGroupAfter"},{text:d.getMessage("Delete_Line"),command:"deleteLine"},{type:"sep"},{text:d.getMessage("Transpose"),
command:"transposeChars"}]},{id:"edit_sort",text:d.getMessage("Sort"),entries:[{text:d.getMessage("Lines"),command:"sortLines"},{text:d.getMessage("Line_Case_Insensitive"),command:"sortLinesInsensitive"}]},{id:"edit_folding",text:d.getMessage("Folding"),entries:[{text:d.getMessage("Fold"),command:"fold"},{text:d.getMessage("Unfold"),command:"unfold"},{text:d.getMessage("Fold_All"),command:"foldAll"},{text:d.getMessage("Unfold_All"),command:"unfoldAll"}]},{id:"edit_sublime_mark",text:d.getMessage("Sublime_Mark"),
entries:[{text:d.getMessage("Set_Sublime_Mark"),command:"setSublimeMark"},{text:d.getMessage("Select_to_Sublime_Mark"),command:"selectToSublimeMark"},{text:d.getMessage("Swap_with_Sublime_Mark"),command:"swapWithSublimeMark"},{text:d.getMessage("Delete_to_Sublime_Mark"),command:"deleteToSublimeMark"},{text:d.getMessage("Yank_Sublime_Mark"),command:"sublimeYank"}]}]},selection:{text:d.getMessage("Selection"),entries:[{text:d.getMessage("Incremental_Find"),command:"selectMatchingPartsOfCurrentSelection"},
{text:d.getMessage("Add_Selection_Above"),command:"selectLinesUpward"},{text:d.getMessage("Add_Selection_Below"),command:"selectLinesDownward"},{text:d.getMessage("Split_into_Lines"),command:"splitSelection"},{type:"sep"},{text:d.getMessage("Incremental_Find"),command:"selectMatchingPartsOfCurrentSelection"},{type:"sep"},{text:d.getMessage("Select_Line"),command:"selectLine"},{text:d.getMessage("Select_Scope"),command:"selectScope"},{text:d.getMessage("Select_Bookmarks"),command:"selectBookmarks"},
{text:d.getMessage("Select_between_Brackets"),command:"selectBetweenBrackets"},{text:d.getMessage("Select_Next_Occurrence"),command:"selectNextOccurrence"}]},find:{text:d.getMessage("Find"),entries:[{text:d.getMessage("Find"),command:"find"},{text:d.getMessage("Replace"),command:"replace"},{text:d.getMessage("Replace_All"),command:"replaceAll"},{type:"sep"},{text:d.getMessage("Find_Next"),command:"findNext"},{text:d.getMessage("Find_Previous"),command:"findPrev"},{text:d.getMessage("Find_Under"),
command:"findUnder"},{text:d.getMessage("Find_All_Under"),command:"findAllUnder"},{text:d.getMessage("Find_Under_Previous"),command:"findUnderPrevious"},{type:"sep"},{text:d.getMessage("Incremental_Find"),command:"selectMatchingPartsOfCurrentSelection"}]},goto:{text:d.getMessage("GoTo"),entries:[{text:d.getMessage("Jump_to_line"),command:"jump"},{text:d.getMessage("Document_Start"),command:"goDocStart"},{text:d.getMessage("Document_End"),command:"goDocEnd"},{text:d.getMessage("Group_Left"),command:"goGroupLeft"},
{text:d.getMessage("Group_Right"),command:"goGroupRight"},{text:d.getMessage("Closing_Bracket"),command:"goToBracket"},{text:d.getMessage("Line_Up"),command:"goLineUp"},{text:d.getMessage("Line_Down"),command:"goLineDown"},{type:"sep"},{text:d.getMessage("Center_Cursor"),command:"showInCenter"},{type:"sep"},{id:"bookmarks",text:d.getMessage("Bookmarks"),entries:[{text:d.getMessage("Toggle"),command:"toggleBookmark"},{text:d.getMessage("Clear_All"),command:"clearBookmarks"},{type:"sep"},{text:d.getMessage("Next_Bookmark"),
command:"nextBookmark"},{text:d.getMessage("Prev_Bookmark"),command:"prevBookmark"}]}]},dev:{text:d.getMessage("Developer"),entries:[{command:"macro",text:d.getMessage("Insert_constructor"),modes:["js"]}].concat(!a.system&&v.editor_enabled&&m?[{type:"sep"},{text:d.getMessage("Run_syntax_check"),command:"lint_script",image:z.get("check"),cb:H},{text:d.getMessage("Auto_Indent_all"),command:"reindentall"}]:[]).concat(a.nnew||a.is_external?[]:[{type:"sep"},{text:d.getMessage("Full_reset"),command:"reset",
image:z.get("script_cancel"),cb:n}]).concat(a.nnew?[{type:"sep"},{id:"templates",text:d.getMessage("Templates"),entries:v.script_templates.map(function(a){return{text:a.name,command:a.name,image:z.get("dot"),cb:function(){if(!I()||confirm(d.getMessage("Really_reset_all_changes_"))){var b=a.value;e.editor&&(v.editor_enabled?(e.editor.mirror.setValue(b),E(!1)):e.editor.value=b)}}}})}]:[])}},L=function(a,b){var c=b[0],d,e;if(d=a[c])return L(d,b.slice(1));a.entries&&a.entries.some(function(a){if(a.command==
c)return e=a,!0;if(a.entries&&(e=L(a,b)))return!0});return e};"file.save_to_disk file.save file.cancel dev.reset find.findNext find.findPrev edit.replace goto.jump edit.reindentall dev.lint_script file.close".split(" ").forEach(function(b){(b=L(S,b.split(".")))&&(b.image?y.appendChild(q.createImageButton(a.uuid,b.id||b.command,b.text,b.image,b.cb||M(b.command))):y.appendChild(q.createButton(b.id||b.command,a.uuid,b.text,b.cb||M(b.command))))});var T=function(a,b){var c=b||CodeMirror.keyMap[v.editor_keyMap],
d,e;Object.keys(c).every(function(b){return c[b]==a?(d=b,!1):!0});if(d)return d;if(c.fallthrough&&(e=CodeMirror.keyMap[c.fallthrough])&&e!==c)return T(a,e)},U=function(b,c){return c.map(function(c,d){if(!c.modes||-1!=c.modes.indexOf(m?"js":"other")){if("sep"==c.type){var e=b+d,g=f("tr","entry sep",a.uuid,"editorsubmenusep_tr"+e),h=w("td",a.uuid,"editorsubmenusep_td"+e),e=w("hr",a.uuid,"editorsubmenusep"+e);h.setAttribute("colspan",4);g.appendChild(h);h.appendChild(e);return g}if(c.command){var k=
b+"_"+c.command,l=c.text,p=c.image,g=T(c.command),h=c.cb||M(c.command),e=!!c.cb||CodeMirror.commands.hasOwnProperty(c.command),n=f("tr","entry "+(e?"":"disabled"),a.uuid,k,"editorsubmenuentry_tr",!0),r;r=p?f("i","far fa-"+p,a.uuid,k,"editorsubmenuentry_i",!0):f("i","far",a.uuid,k,"editorsubmenuentry_i",!0);p=w("td",a.uuid,"editorsubmenuentry_td_i"+k);p.appendChild(r);r=f("td","label",a.uuid,"editorsubmenuentry_td_l"+k);r.textContent=l;k=f("td","shortcut",a.uuid,"editorsubmenuentry_td_m"+k);k.setAttribute("colspan",
2);g&&(k.textContent=g);n.appendChild([p,r,k]);e&&n.addEventListener("click",h);return n}h=b+c.id;e=c.text;n=c.image;g=f("tr","entry list",a.uuid,h,"editorsubmenulistentry",!0);k=n?f("i","far fa-"+n,a.uuid,h,"editorsubmenulistentry_i",!0):f("i","far",a.uuid,h,"editorsubmenulistentry_i",!0);n=w("td",a.uuid,"editorsubmenulistentry_td_i"+h);n.appendChild(k);k=f("td","label",a.uuid,"editorsubmenulistentry_td_l"+h);k.textContent=e;l=f("td",a.uuid,"editorsubmenulistentry_td_m"+h);e=w("td",a.uuid,"editorsubmenulistentry_td_s"+
h);g.appendChild([n,k,l,e]);n=f("span","submenulist",a.uuid,"editorsubmenulistcontent"+h);k=f("span","submenumore",a.uuid,"editorsubmenulistmore"+h);l=f("i","more far fa-caret-right",a.uuid,h,"editorsubmenulistentrymore_i",!0);k.appendChild([l,n]);e.appendChild([l,k]);h=U(h,c.entries);if(0<h.length)return n.appendChild(h),g}}).filter(function(a){return a})};Object.keys(S).forEach(function(a){var b=S[a],c=K(a,b.text);a=U(a,b.entries);0<a.length&&(A.appendChild(c.elem),c.content.appendChild(a))});n=
f("textarea","editorta",a.uuid,"editor");n.setAttribute("wrap","off");n.setAttribute("spellcheck","false");var H=f("td","editor_outer",a.uuid,"edit"),V=f("div","editor_100 editor_border",a.uuid,"edit");H.appendChild(V);r.appendChild(p);e.inserted||(V.appendChild(n),e.appendChild(H));x[a.uuid].saveToDisk=function(){if(e.editor){var b=v.editor_enabled?e.editor.mirror.getValue():e.editor.value;t.wait();return ra().done(function(){var c=new Blob([b],{type:"text/plain"});saveAs(c,u.safeFileName(a.name+
(a.is_external?"":".user.js")))}).always(function(){t.hide()})}};a.system||(x[a.uuid].saveEm=a.is_external?function(b){if(e.editor){var c=v.editor_enabled?e.editor.mirror.getValue():e.editor.value;Ib(a.script_uuid,c,{url:a.file_url,mimetype:a.mimetype,auto_save:b&&b.auto_save}).done(function(a){a.success?E(!1):a.aborted||b&&b.auto_save||(a.messages&&a.messages.errors&&a.messages.errors.length?u.alert(a.messages.errors.join("\n")):u.alert(d.getMessage("Unable_to_parse_this_")))})}}:function(b){if(e.editor){var c=
!0;v.showFixedSrc&&(c=confirm(d.getMessage("Do_you_really_want_to_store_fixed_code_",d.getMessage("Show_fixed_source"))));var h=v.editor_enabled?e.editor.mirror.getValue():e.editor.value;c&&Pa(a.uuid,h,{clean:!1,new_script:a.nnew,auto_save:b&&b.auto_save,reload:!0,lastModTime:x[a.uuid].saveEm_lastModTime}).done(function(c){c.installed?a.nnew?D(null,!0,!1):(E(!1),c.lastModified&&(a.lastModTime=c.lastModified)):c.aborted||b&&b.auto_save||(c.messages&&c.messages.errors&&c.messages.errors.length?u.alert(c.messages.errors.join("\n")):
u.alert(d.getMessage("Unable_to_parse_this_")))});return c}});var ya=b.insertTab(null,c.navid,k,h,function(a){a.then(function(){J.setSub(c.navid);if(c.on_tab_select)c.on_tab_select()})},c.on_tab_close);ya.setHeading(c.tab_name||d.getMessage("Editor"),50);J.registerListener(a.uuid,c.navid,function(){ya.select();v.editor_enabled&&e.editor&&(e.editor.refresh(),e.editor.mirror.focus())});if(l)return ba["editor"+a.uuid];var N=function(a,b,c,d){a=d.getValue();if((a=d.getHelper(CodeMirror.Pos(0,0),"lint")(a,
c,d))&&a.then)return a.then(b);b(a)},Q=function(a){xa("editor_theme",a,!0).done(function(){fb("Theme switched to "+a)})},R=function(){v.editor_autoSave&&I()&&P(a.uuid,"saveEm",{auto_save:!0})};b={getTab:function(){return ya},getEditor:function(){if(e.editor)return v.editor_enabled?e.editor.mirror:{save:F}},onShow:function(){(function(){if(a.referrer&&void 0===a.code){var b=C();la(u.copy(c.tree_opts||{},{referrer:a.referrer+"."+c.treeid,uuid:a.uuid}),function(c){c.items?(a.code=c.items[0],b.resolve()):
b.reject();t.hide()});return b.promise()}return C.Pledge()})().done(function(){var b=h.getElementsByTagName("textarea");x[a.uuid].lastI=function(){return a};if(b.length&&!e.editor){var b=b[0],k=function(){e.editor&&E(!!e.editor.mirror.historySize().undo)};if(v.editor_enabled){var f=b.parentNode;f.removeChild(b);e.editor=new MirrorFrame(f,{mode:g,theme:v.editor_theme,fontSize:v.editor_fontSize,themeOptions:{all:Da.getEditorThemes().map(function(a){return a.value}),onChange:Q},value:a.code,indentUnit:Number(v.editor_indentUnit),
indentWithTabs:"tabs"==v.editor_indentWithTabs,smartIndent:"classic"!=v.editor_tabMode,indentByTab:"indent"==v.editor_tabMode,electricChars:"true"==v.editor_electricChars.toString(),lineNumbers:!0,lineWrapping:v.editor_lineWrapping,extraKeys:{Enter:"newlineAndIndentContinueComment"},keyMap:v.editor_keyMap,bookmarkGutter:!0,gutters:["gutter","CodeMirror-linenumbers","CodeMirror-foldgutter","CodeMirror-lint-markers","CodeMirror-bookmarks"],matchBrackets:!0,foldGutter:!0,styleActiveLine:!0,specifyMoreJsTokens:m,
styleSelectedText:!0,autoTrimTrailingSpace:"true"==v.editor_trimTrailingSpacesFromModifiedLines.toString(),hintOptions:m?{keywords:Object.keys(Ta.globals)}:void 0,lint:m?{lintOnChange:v.editor_autoLint,autoLintMaxLen:v.editor_autoLintMaxLen,async:!0,getAnnotations:N,hint_config:v.editor_linter_config||Ta.config}:void 0,showTrailingSpace:v.editor_highlightTrailingWhitespace},{save:F,close:D},{change:k,blur:R},d.getMessage)}else e.editor=b,b.value=a.code;if(c.on_editor_load)c.on_editor_load()}}).fail(function(){D(null,
!1,!0)})},onClose:function(b){var c=function(){e.editor=null;delete x[a.uuid].lastI};if(!b&&I())return(b=confirm(d.getMessage("There_are_unsaved_changed_")))&&c(),!b;c();return!1}};return ba["editor"+a.uuid]=b},rb=function(a,b,c){x[a.uuid]||(x[a.uuid]={});var e,g,m=a.icon&&!a.nativeScript,k=[];a.nativeScript||k.push("clickable");a.blacklisted&&k.push("crossedout");var l=f("span",k.join(" "),a.uuid,"sname"),h=f(m?"img":"span","nameNicon16 icon16 "+(m?"nameNicon16":"nameNOicon16"),a.uuid,"sname_img"),
r=f("span","nameNname16 "+(a.enabled?"":"greyed"),a.uuid,"sname_name");l.appendChild(h);var k=Oa(a),p=d.getTranslation(a,"name");r.textContent=p;var n=w("span",a.uuid,"spos");n.textContent=a.position||"";p=w("span",a.uuid,"sversion");p.textContent=a.version?a.version:"";m&&(h.src=a.icon);var m=[],h=function(a,b,c){var d=f("span",c||"",a.uuid,"wrap");b&&("Array"===u.toType(b)?u.each(b,function(a){d.appendChild(a)}):d.appendChild(b));return d},t=function(){window.setTimeout(function(){for(var d=Object.keys(Z),
e,h=0;e=d[h];h++)if(e=Z[e].script,e.uuid==a.uuid){Aa(b,[e],null,c);break}Ia()},1)},F=function(b,c){void 0===c&&(c=!b);g&&g.onClose&&g.onClose(b)||(a.uuid&&J.is(a.uuid)&&J.clear(),e&&(e.remove(),e=null),delete ba["tab"+a.uuid],delete ba["editor"+a.uuid],l.parentNode&&l.parentNode.removeChild(l),c&&t())},D=function(a){if(g&&g.onSelect)g.onSelect(a)},E=x[a.uuid].scriptClick=function(h,k){if(!e){var m=null;a.nnew?(m=f("div","head_icon",a.uuid,"details_h"),m.appendChild(q.createIcon(a.image_id,"",a.uuid,
"new_script_head"))):m=w("div",a.uuid,"details_h");var l=w("div",a.uuid,"details_c");e=c.insertTab(null,a.uuid,m,l,D,a.nnew?null:F);a.nnew||e.setHeading(d.getMessage("Edit")+" - "+d.getTranslation(a,"name"),50);g=Eb(e,a,b,l,F)}if(g&&g.onShow)g.onShow();e.show();h&&1==h.button||k||e.select();r.setAttribute("open","true")};"true"==r.getAttribute("open")&&E(null,!0);var H=function(a,b){var c=a.getTime(),d=b.getTime(),e=Math.abs(c-d),c=Math.round(e/6E4),d=Math.round(e/36E5),e=Math.round(e/864E5);return 60>=
c?c+" min":48>=d?d+" h":e+" d"},y=w("span","",a.uuid,"last_updated",!0),B="?";if(a.nativeScript||a.nnew||a.system)B="";else if(x[a.uuid].scriptUpdate=function(){var b=y.textContent;y.textContent="";y.appendChild(q.createIcon(z.get("download"),"down",a.uuid,"spinner"));Jb(a.uuid,function(c){y.textContent=b;c?($(y).addClass("green"),y.title=d.getMessage("There_is_an_update_for_0name0_avaiable_",a.name),F(!0),gb()):($(y).addClass("red"),y.title=d.getMessage("No_update_found__sry_"))})},a.options.check_for_updates&&
a.file_url&&"none"!=a.file_url?(y.addEventListener("click",function(){P(a.uuid,"scriptUpdate")}),y.setAttribute("class","clickable"),y.title=d.getMessage("Check_for_Updates")):(y.setAttribute("class","greyed italic"),y.title=d.getMessage("Update_check_is_disabled")),a.lastModified||a.lastUpdated)try{B=H(new Date,new Date(a.lastModified||a.lastUpdated))}catch(L){console.log("o: error calculating time "+L.message)}y.textContent=B;var C=w("div",a.uuid,"imported"),O="";M.push(function(){v.sync_enabled&&
(O=a.nativeScript||a.nnew||a.system?"":a.sync&&a.sync.imported?a.sync.imported==ta.types.eCHROMESYNC?A.RUNTIME.FIREFOX?'<img src="'+z.brand("firefox")+'" class="icon16" title="Firefox Sync"/>':'<img src="'+z.brand("chrome")+'" class="icon16" title="Google Sync"/>':a.sync.imported==ta.types.eGDRIVE?'<img src="'+z.brand("gdrive")+'" class="icon16" title="Google Drive"/>':a.sync.imported==ta.types.eDROPBOX?'<img src="'+z.brand("dropbox")+'" class="icon16" title="Dropbox"/>':a.sync.imported==ta.types.eWEBDAV?
'<img src="'+z.brand("webdav")+'" class="icon16" title="WebDAV"/>':'<img src="'+rea.extension.getURL("/layout/default/images/update.png")+'" class="icon16" />':"",C.innerHTML=O,C=null)});var G,H=w("span",a.uuid,"hp");if(a.origin){G=w("a",a.uuid,"hp_origin");G.setAttribute("href",a.origin.url);G.setAttribute("target","_blank");var K=q.createImage(z.origin(a.origin.token),"",a.uuid,a.origin.token);G.appendChild(K);H.appendChild(G)}!k||a.origin&&a.origin.url===k||(G=w("a",a.uuid,"hp_script"),G.setAttribute("href",
k),G.setAttribute("target","_blank"),K=q.createIcon(z.get("home"),"",a.uuid,"homepage",""),G.appendChild(K),H.appendChild(G));x[a.uuid].saveEm_lastModTime=a.lastModified;x[a.uuid].fullReset=function(c){Pa(a.uuid,null,{clean:!0,reload:!0}).done(c||function(){});b.parentNode.removeChild(b)};x[a.uuid].reportAnIssue=function(b){Kb(a.uuid,b)};x[a.uuid].deleteScript=function(c,e){var h;a.nativeScript?(h=e||confirm(d.getMessage("Really_delete_0name0__",a.name)),1==h&&(Qa(a.uuid,"installed","false"),b.parentNode.removeChild(b))):
(h=e||confirm(d.getMessage("Really_delete_0name0__",a.name)),1==h&&(Pa(a.uuid,null,{reload:!e}),b.parentNode.removeChild(b)))};G=[];if(a.nativeScript){x[a.uuid].importNativeScript=function(c,e){1==(e||confirm(d.getMessage("Really_import_0name0__",a.name)))&&(Qa(a.uuid,"imported","true"),b.parentNode.removeChild(b))};var N=q.createIcon(z.get("import"),"",a.uuid,"import",d.getMessage("Import"),function(){P(a.uuid,"importNativeScript")});q.addClass(N,"hidden");G.push(N);M.push(function(){v.native_import&&
q.toggleClass(N,"hidden")})}!a.nnew&&!a.system&&a.origin&&a.origin.abuse_url&&(K=q.createIcon(z.get("flag"),"",a.uuid,"issue",d.getMessage("Report_an_issue_to_the_script_hoster_"),function(){P(a.uuid,"reportAnIssue","hoster")}),G.push(K));a.nnew||a.system||!a.origin&&!a.supportURL||(K=q.createIcon(z.get("bug"),"",a.uuid,"bug",d.getMessage("Report_a_bug"),function(){P(a.uuid,"reportAnIssue","author")}),G.push(K));a.nnew||a.system||a.nativeScript||(a.remote_url&&(K=q.createIcon(z.get("cloud"),"",a.uuid,
"cloud_edit",d.getMessage("Edit"),function(){sendMessage({method:"newTab",url:a.remote_url},function(){})}),G.push(K)),K=q.createIcon(z.get("edit"),"",a.uuid,"edit",d.getMessage("Edit"),function(){P(a.uuid,"scriptClick")}),G.push(K));a.nnew||a.system||(K=q.createIcon(z.get("delete"),"",a.uuid,"delete",d.getMessage("Delete"),function(){P(a.uuid,"deleteScript")}),G.push(K));A.RUNTIME.MOBILE?l.inserted||a.nativeScript||r.addEventListener("click",function(){$(b).toggleClass("show_details")}):l.inserted||
a.nativeScript||(l.addEventListener("click",E),l.addEventListener("auxclick",E));l.appendChild(r);K=[a.name];a.description&&K.push(d.getTranslation(a,"description"));a.blacklisted&&(K=[a.blacklisted]);l.title=K.join("\n\n").replace(/\"/g,'"');m.push(a.nnew||a.system?null:{element:Lb(a),style:"script_sel"});m.push(n);m.push(function(){var b=null,b=a.blacklisted?"enabler_warning":a.enabled?a.contexter?"enabler_enabled enabler_later":"enabler_enabled":"enabler_disabled",c=a.blacklisted||(a.enabled?d.getMessage("Enabled"):
d.getMessage("Disabled")),b=q.createEnabler(b,a.uuid,"enabled",{append:"enabled",disabled:!!a.blacklisted,title:c},function(){P(a.uuid,a.nativeScript?"switchNativeEnabled":"switchEnabled")});x[a.uuid].switchEnabled=function(b,c,d){void 0===c&&(c=!a.enabled);ia(a.uuid,{enabled:c},d)};x[a.uuid].switchNativeEnabled=function(b,c,d){void 0===c&&(c=!a.enabled);Qa(a.uuid,"enabled",c,d)};return b}());m.push({element:l,style:"script_name"});if(A.RUNTIME.MOBILE){n=function(b,c,d,e){var h=f("dt","script_info "+
(e?e:""),a.name,a.uuid,"dt_mapping"+c);e=f("dd","script_info "+(e?e:""),a.name,a.uuid,"dd_mapping"+c);h.textContent=c;"string"===typeof d?e.textContent=d:e.appendChild(d);b.appendChild([h,e])};K=f("dl","script_details",a.name,a.uuid,"script_details_dl");l.appendChild(K);n(K,d.getMessage("Version"),p);n(K,d.getMessage("Type"),hb(a),"script_type");n(K,d.getMessage("Sites"),ib(a));var S;(S=jb(a))&&n(K,d.getMessage("Features"),S);k&&n(K,d.getMessage("Homepage"),H);B&&n(K,d.getMessage("Last_updated"),
y);m.push(h(a,G,"actions"))}else for(m.push({element:p,style:"script_version"}),m.push(hb(a)),m.push(C),m.push(ib(a)),m.push(jb(a)),m.push(H),m.push(y),m.push(Mb(a)),m.push(h(a,G,"actions")),S=m.length;10>S;S++)m.push(null);J.registerListener(a.uuid,function(){E()});a.nnew&&M.push(function(){E(null,!0)});return m},hb=function(a){var b=f("span","script_type","",a.uuid,"pos_type",!0);if(a.nnew)return b;a.nativeScript?(a=q.createImage(a.icon,"",a.uuid,"chrome_ext",d.getMessage("This_is_a_chrome_extension")),
b.appendChild(a)):a.userscript&&(a=q.createImage(z.origin("uso"),"",a.uuid,"user_script",d.getMessage("This_is_a_userscript")),b.appendChild(a));return b},jb=function(a){var b,c,e,g=null,f=[];if(a.nnew)return null;a.system&&(b=q.createIcon(z.get("lock"),"",a.uuid,"lock",d.getMessage("This_is_a_system_script")),f.push(b));a.warnings&&a.warnings.forEach(function(c,d){b=q.createIcon(z.get("critical"),"compat",a.uuid,"warning_"+d,c);$(b).addClass("flashing");f.push(b)});if(a.awareOfChrome||a.nativeScript)b=
q.createImage("https://www.google.com/images/icons/product/chrome-16.png","",a.uuid,"chrome_mode",d.getMessage("This_script_runs_in_Chrome_mode")),f.push(b);if(a.nativeScript)return g;a.requires.length&&(e=!a.requires.filter(function(a){return a.modified}).length,b=q.createIcon(z.get("script_download")+(e?"":" red"),"",a.uuid,"requires",u.map(u.select(a.requires,function(a){return a&&a.url}),function(a){return a.url}).join("\n"),function(){J.set(a.uuid,"externals")}),f.push(b));a.resources.length&&
(e=!a.resources.filter(function(a){return a.modified}).length,b=q.createIcon(z.get("resources")+(e?"":" red"),"",a.uuid,"resources",u.map(u.select(a.resources,function(a){return a&&a.url}),function(a){return a.url}).join("\n"),function(){J.set(a.uuid,"externals")}),f.push(b));e=!1;var k={includes:!0,matches:!0};for(c in k)if(a[c]){for(k=0;k<a[c].length;k++)if(a[c][k]&&(0==a[c][k].search(/\/\^?http(s|\.\*?|s\?|\[[^\]]*s[^\]]*\]|\([^\)]*s[^\)]*\))+/)||0==a[c][k].search(/http[s\*]{1,1}|\*/))){b=q.createIcon(z.get("encrypted"),
"",a.uuid,"encrypt",d.getMessage("This_script_has_access_to_https_pages"));f.push(b);e=!0;break}if(e)break}var l={};a.grant.forEach(function(a){l[a]=!0});l.GM_xmlhttpRequest&&(b=q.createIcon(z.get("web"),"",a.uuid,"web",d.getMessage("This_script_has_full_web_access")),f.push(b));l.GM_setValue&&(b=q.createIcon(z.get("db"),"",a.uuid,"db",d.getMessage("This_script_stores_data")),f.push(b));l.unsafeWindow&&(b=q.createIcon(z.get("windowlist"),"",a.uuid,"unsafeWindow",d.getMessage("This_script_has_access_to_webpage_scripts")),
f.push(b));for(c in a.options)if(-1!=c.search("compat_")&&a.options[c]){b=q.createIcon(z.get("critical"),"compat",a.uuid,"crit",d.getMessage("One_or_more_compatibility_options_are_set"));f.push(b);break}f.length&&(g=w("span","",a.uuid,"pos_features",!0),g.appendChild(f,!0));return g},kb=!1,ab=function(a){if(!kb){var b=d.getLocale(),c=$("<div>").hide(),e=function(a){a?(c.html(""),c.append($('<div class="contrib_iframe" style="font-size: 2.5em;"></div>').append($('<div style="padding-top: 150px;">').text(a))),
window.setTimeout(e,1E3)):(c.fadeOut(1E3),window.setTimeout(t.hideDialog,1E3))};a=$('<iframe src="https://www.tampermonkey.net/contrib.php?embedded=2'+(b?"&locale="+b:"")+"&src="+(a||"e")+'" class="contrib_iframe"></iframe>');var g=[$('<button class="contrib_button">').html(d.getMessage("Remind_me_later")).click(function(){ma("later");e(d.getMessage("Ok"))}),$('<button class="contrib_button">').html(d.getMessage("I_contributed_already")).click(function(){ma("contributed");e(d.getMessage("Thank_you_very_much_"))}),
$('<button class="contrib_button">').html(d.getMessage("I_dont_want_to_contribute")).click(function(){ma("hide");e(d.getMessage("Ok"))})],f=function(){k&&window.clearTimeout(k);g.forEach(function(a){a.prop("disabled",!1)})};g.forEach(function(a){a.prop("disabled",!0)});c.append(a,g);a.bind("load",f);var k=window.setTimeout(function(){k=null;f()},15E3),l=function(){var a=t.dialog(c[0]);!0===a?(c.fadeIn(1E3),ma("dialog")):void 0===a&&window.setTimeout(l,500);kb=!0};l();window.addEventListener("message",
function(a){var b,g=a.data.clicked||a.data.type;b=a.data.amount;var k=a.data.currency,f=a.data.redirect_url;g&&(f&&za(f,!0),a.data.success?(b=$(".contrib_iframe"),k=b.data("oheight"),!k||0>k||1E3<k||(b.animate({height:k},1E3),ma("contributed",g,{id:a.data.id}))):a.data.clicked&&(ma("clicked",g,{amount:b||"?",currency:k||"?"}),$(".contrib_button").remove(),c.append($('<button class="contrib_button">').html(d.getMessage("Ok")).click(function(){e()})),a.data.enlarge&&(b=$(".contrib_iframe"),b.data("oheight",
b.height()),b.animate({height:740},1E3))))},!1)}},Nb=function(){var a=null,b=null,c=null,d=0,g=0,f=0,k=function(b){var d=c.x+b.pageX;a.style.top=c.y+b.pageY+"px";a.style.left=d+"px"},l,h,r,p=function(c){if(a&&!l){var t,E=null,H,y,u,v;k(c);h&&(window.clearTimeout(h),h=null);for(;E!=f;)E=f,H=b.previousSibling,y=b.nextSibling,u=b.parentNode,v=n(b),c.pageY>v.y+d+g&&y?(u.removeChild(y),u.insertBefore(y,b),f++,t=!1):c.pageY<v.y&&1<f&&(u.removeChild(H),y?u.insertBefore(H,y):u.appendChild(H),f--,t=!0);E=
Math.min(.03*document.documentElement.clientHeight,100);if(void 0!==t){y=t?$(H):$(y);if(y.length&&!q.isScrolledIntoView(y,{padding:E})){t=t?y.offset().top-E-y.height():y.offset().top-document.documentElement.clientHeight+E+2*y.height();l=!0;var x=t-document.body.scrollTop;$("html, body").animate({scrollTop:t},0,function(){window.setTimeout(function(){l=!1;h=window.setTimeout(function(){h=null;r===c&&p({pageX:r.pageX,pageY:r.pageY+x})},100)},100)})}c.stopPropagation&&(c.stopPropagation(),c.preventDefault());
r=c;return!1}}},n=function(a){a=a.getBoundingClientRect();return{x:a.left+window.pageXOffset,y:a.top+window.pageYOffset}},t=function(d){a.style.position="static";var e={};e[a.key]=f;ia(a.uuid,e);a=b=c=null;document.removeEventListener("mousemove",p);document.removeEventListener("scroll",p);document.removeEventListener("mouseup",t);d.stopPropagation();d.preventDefault();return!1};return{start:function(h,l){var r=this.parentNode.parentNode,q=r.parentNode,y=q.parentNode.parentNode;a=this;b=q;d=b.offsetHeight;
g=b.offsetHeight-r.clientHeight;c=n(y);c.x=-c.x-a.offsetWidth/2;c.y=-c.y-b.offsetHeight/2+2*g;a.style.position="absolute";k(h);f=l;document.addEventListener("mousemove",p);document.addEventListener("scroll",p);document.addEventListener("mouseup",t);h.stopPropagation();h.preventDefault();return!1}}}(),Mb=function(a){var b=f("span","sorting","",a.uuid,"pos_images",!0);if(a.nnew||a.nativeScript)return b;"pos"==ha()&&"up"==ka()||b.setAttribute("style","display: none;");if(1<a.position||a.position<a.positionof){var c=
f("span","clickable movable","position",a.uuid,!0);c.innerHTML="&#9776;";c.title=d.getMessage("Click_here_to_move_this_script");c.uuid=a.uuid;c.key="position";c.addEventListener("mousedown",function(b){Nb.start.apply(this,[b,a.position])});b.appendChild(c)}return b},ib=function(a){var b=w("span","",a.uuid,"site_images"),c=null;b.inserted&&(c=b,c.setAttribute("id",c.id+"foo"),b=w("span","",a.uuid,"site_images"));Ja.topIcons(a,7).forEach(function(a){b.appendChild(a,!0)});c&&c.parentNode.removeChild(c);
return b},ob=function(a){var b=f("div","search_filter",a.name,a.id,"filter");if(b.inserted)return b;var c=$(b);x.filter={onShow:function(a){l(!0);a&&$(t).focus()},onHide:function(){t.value="";l(!0,1)}};var e=null,g,m,k,l=function(a,b){if(!g||a)e&&window.clearTimeout(e),w.show(),e=window.setTimeout(function(){m=r;k=t.value;for(var a=document.getElementsByName("scriptselectors"),b=[],d=0;d<a.length;d++)b.push(a[d]);g=!0;"matching_url"!=m&&"auto"!=m||!k.match(h.matching_url.match)?a=C.Pledge():(p=h.matching_url.update_interval||
p,a=Ob(k));a.then(function(a){var d=new RegExp(u.escapeForRegExp(k),"i"),e=b.map(function(b){return function(){var e,g,f,l;return(g=Z[b.s_id])&&(f=g.script)&&(l=g.dom)&&m==r&&k==t.value?function(){if(c.is(":visible")){if("auto"==m)return C.or(Object.keys(h).map(function(b){return function(){var c=h[b];return c.check?c.check(f,c.ignore_case?d:k,a):C.Breach()}}));var b=h[m];if(b.check)return b.check(f,b.ignore_case?d:k,a)}else return C.Pledge();return C.Breach()}().done(function(){e=!0}).fail(function(){e=
!1}).always(function(){$(l).toggle(!!e);b.is_hidden=!e}):C.Breach()}});return C.onebyone(e)}).always(function(){g=!1;m!=r||k!=t.value?l(!1,1):w.fadeOut()})},b||p)},h={auto:{name:d.getMessage("Auto"),update_interval:500},name:{name:"@name",sync:function(a,b){return-1!=a.name.search(b)},ignore_case:!0},namespace:{name:"@namespace",sync:function(a,b){return a.namespace&&-1!=a.namespace.search(b)},ignore_case:!0},author:{name:"@author",sync:function(a,b){return a.author&&-1!=a.author.search(b)},ignore_case:!0},
grant:{name:"@grant",default:"GM_",sync:function(a,b){return a.grant&&0<a.grant.filter(function(a){return-1!=a.search(b)}).length},ignore_case:!0},includes:{name:"@include/@match",sync:function(a,b){return a.includes&&0<a.includes.filter(function(a){return-1!=a.search(b)}).length||a.matches&&0<a.matches.filter(function(a){return-1!=a.search(b)}).length},ignore_case:!0},code:{name:d.getMessage("Source_Code"),async:function(a,b){var c=C();Pb(a.uuid,{code:b.toString()},function(a){(a?c.resolve:c.reject)()});
return c.promise()},ignore_case:!0},comment:{name:d.getMessage("Comment"),sync:function(a,b){return a.comment&&-1!=a.comment.search(b)},ignore_case:!0},url:{name:d.getMessage("Update_URL_"),default:"https://",sync:function(a,b){return a.file_url&&-1!=a.file_url.search(b)},ignore_case:!0},matching_url:{name:d.getMessage("Matching_URL"),update_interval:1500,default:"http://",match:/^https?:\/\/.*/,sync:function(a,b,c){return c&&-1!=c.indexOf(a.uuid)}}};Object.keys(h).forEach(function(a){var b=h[a];
b.check=b.sync||b.async?function(){if(b.sync)return b.sync.apply(this,arguments)?C.Pledge():C.Breach();if(b.async)return b.async.apply(this,arguments)}:null});var r="auto",p=h.auto.update_interval,n=q.createDropDown(d.getMessage("Filter_by"),{value:0,uuid:"sms-filter",name:"select"},Object.keys(h).map(function(a){return{name:h[a].name,value:a}}),function(){var a;a=this.value;a!=r&&(r=a,p=((a=h[r])?a.update_interval:null)||h.auto.update_interval,a=(a?a.default:null)||"",t.value=t.value||a,l())});n.elem.setAttribute("class",
"label");var t=f("input","filter_text","sms","all",null);t.setAttribute("spellcheck","false");var v="";t.inserted||t.addEventListener("keyup",function(){v!=t.value&&(v=t.value,l())});var w=$(q.createIcon(z.get("download"),"wait_for_filter",a.uuid));w.attr("style","vertical-align: middle;");w.hide();b.appendChild(n.elem);b.appendChild(t);b.appendChild(w[0]);ca.filter&&M.push(function(){x.multiselect.toggleRow(!0,!0);t.value=ca.filter});return b},Y=[],Lb=function(a){var b=w("input","",a.uuid,"sel");
b.type="checkbox";b.s_id=a.uuid;b.name="scriptselectors";b.s_type=a.nativeScript?"n":"s";b.inserted||b.addEventListener("click",function(a){Y=[];b&&Y.push(b);a.ctrlKey||a.metaKey?x.multiselect.un_selectAll():x.multiselect.single_click()});return b},nb=function(a){var b=f("input","multiselectcb","sms","all",null),c=f("div","filter multiselectcb clickable","sms2","all",null);b.inserted||(b.type="checkbox",b.addEventListener("click",x.multiselect.un_selectAll),c.addEventListener("click",function(){x.multiselect.toggleRow()}));
var e=0,g=[{name:d.getMessage("__Please_choose__"),value:0},{name:d.getMessage("Enable"),value:1},{name:d.getMessage("Disable"),value:2},{name:d.getMessage("Toggle_Enable"),value:7}];(A.RUNTIME.CAN_SAVEAS_ZIP||"undefined"!==typeof Blob)&&g.push({name:d.getMessage("Export"),value:3});var g=g.concat([{name:d.getMessage("Trigger_Update"),value:5},{name:d.getMessage("Factory_Reset"),value:8},{name:d.getMessage("Remove"),value:6}]),g=q.createDropDown(d.getMessage("Apply_this_action_to_the_selected_scripts"),
{value:0,uuid:"sms-select",name:"select"},g,function(){0==this.value?m.setAttribute("disabled","true"):m.removeAttribute("disabled");e=this.value}),m=q.createButton("MultiSelectButton","start_button",d.getMessage("Start"),function(){if(0==e)console.log("option: ?!?!");else{var a=null;6==e?a=d.getMessage("Really_delete_the_selected_items_"):8==e&&(a=d.getMessage("Really_factory_reset_the_selected_items_"));if(!a||confirm(a)){for(var b=document.getElementsByName("scriptselectors"),c=[],a=0;a<b.length;a++)c.push(b[a]);
for(var b={},g,f=!1,m=100,a=0;a<c.length;a++)if(c[a].checked&&!c[a].is_hidden)if(1==e||2==e||7==e){g="n"==c[a].s_type?"switchNativeEnabled":"switchEnabled";var q;if(7==e){var u=Z[c[a].s_id]?Z[c[a].s_id].script:null;u&&(q=!u.enabled)}else q=1==e;void 0!==q&&(P(c[a].s_id,g,null,q,!1),f=!0)}else 3==e?b[c[a].s_id]=!0:5==e?(g="scriptUpdate",P(c[a].s_id,g)):6==e?(g="deleteScript",P(c[a].s_id,g,null,!0),f=!0,m=1500):8==e&&(g="fullReset",P(c[a].s_id,g),f=!0,m=1500);3==e&&(t.wait(),Ba(b,{storage:B.script_storage,
externals:B.include_externals}).then(function(a){t.wait();return A.RUNTIME.CAN_SAVEAS_ZIP?da.zip.create(a.scripts).progress(t.wait):da.json.create(a.scripts).then(function(a){return new Blob([a],{type:"text/plain"})})}).then(function(a){return ra().done(function(){saveAs(a,"tampermonkey_scripts"+(A.RUNTIME.CAN_SAVEAS_ZIP?".zip":".txt"))})}).always(function(){t.hide()}));f&&(t.wait(d.getMessage("Please_wait___")),window.setTimeout(function(){gb()},m))}}});m.setAttribute("class","action_button");m.setAttribute("disabled",
"true");g.elem.appendChild(m);a=f("div","actions",a.name,a.id,"actions");a.appendChild(g.elem);g=q.createButton("MultiSelectButton","close_button",d.getMessage("Close"),function(){x.multiselect.toggleRow(!1)});$(g).addClass("close_button");return{selAllm:b,selAll:c,actionBox:a,close:g}};(function(){var a=0;x.multiselect={};var b=!1;x.multiselect.toggleRow=function(a,d){var g=$(".multiselect");void 0===a&&(a=!b);a?(b=!0,g.addClass("multiselectvisible"),x.filter.onShow(d)):(b=!1,g.removeClass("multiselectvisible"),
x.filter.onHide(),x.multiselect.un_selectAll(!1))};x.multiselect.single_click=function(){for(var b=0,d=document.getElementsByName("scriptselectors"),g=!0,f=!1,k=!1,l=!0,h=!1,q=!1,p=0,n=0;n<d.length;n++){"n"==d[n].s_type?(k=!0,g=g&&d[n].checked,f=f||d[n].checked):"s"==d[n].s_type&&(q=!0,l=l&&d[n].checked,h=h||d[n].checked);var t=$(d[n]).closest("tr");d[n].checked?(p++,t.addClass("selected")):t.removeClass("selected")}!k||!g||q&&!l&&h||(b+=1);!q||!l||k&&!g&&f||(b+=2);b!=a&&(a=b,$(".multiselectcb").prop("checked",
0!=b?"checked":""));p&&x.multiselect.toggleRow(!0);x.multiselect.checkScroll&&x.multiselect.checkScroll()};x.multiselect.un_selectAll=function(b){3<++a&&(a=0);var d=!1,g=0,f=document.getElementsByName("scriptselectors");Y=[];!0===b&&(a=2);for(var k=0;k<f.length;k++){var l=$(f[k]).closest("tr");!1===b?(f[k].checked=!1,l.removeClass("selected")):(0!=k||1!=a&&3!=a||"s"!=f[k].s_type||3<++a&&(a=0),d|="s"==f[k].s_type,f[k].checked=3==a||1==a&&"n"==f[k].s_type||2==a&&"s"==f[k].s_type,f[k].checked?(g++,l.addClass("selected"),
Y.push(f[k])):l.removeClass("selected"));g&&x.multiselect.toggleRow(!0)}void 0===b?1<a&&!d&&(a=0):b||(a=0);$(".multiselectcb").prop("checked",0!=a?"checked":"")}})();var na=null,Q=function(){na&&(window.clearTimeout(na),na=null)},R=function(){Ra(d.getMessage("Operation_completed_successfully"),"button_ok","notice")},fb=function(a,b){void 0===b&&(b="button_ok");Ra(a,b,"information",8E3)},eb=function(a,b){void 0===b&&(b="error");Ra(a,b,"warning",8E3)},Ra=function(a,b,c,d){void 0===d&&(d=3E3);Ka({key:"success",
text:a,image:b,class:c,delay:500,timeout:d,done:function(){}})},Ka=function(a){var b,c=a.key||"general";(b=lb[c])&&$(b).remove();lb[c]=q.createGobalHint(a,$("body > div.status")[0])},W=function(){na||(na=window.setTimeout(function(){na=null;t.wait(d.getMessage("Please_wait___"))},500))},sa=null,oa=null,X=function(a,b){null!=sa?(window.clearTimeout(sa),sa=null,X(a?a:oa.items,a?b:oa.with_scripts)):(oa={items:a,with_scripts:b},sa=window.setTimeout(function(){sa=null;oa.with_scripts&&(Z={});Aa(null,oa.items,
null,N);t.hide();Ia();oa=null},50))},Ob=function(a){var b=C();sendMessage({method:"determineScriptsToRun",url:a},function(a){b.resolve(a.scripts||[])});return b.promise()},ma=function(a,b,c){var d=C();sendMessage({method:"begEvent",action:a,type:b,extra:c},function(a){d.resolve(a)});return d.promise()},za=function(a,b){try{var c=function(){b&&A.OPTIONPAGE.CLOSE_ALLOWED&&window.close()};b?sendMessage({method:"newTab",url:a},c):rea.tabs.getSelected(null,function(d){rea.tabs.sendMessage(d.id,{method:"loadUrl",
url:a,newtab:b},c)})}catch(d){console.log("lU: "+d.message)}},yb=function(a,b){var c=C();try{W(),sendMessage({method:"installScript",url:a,reload:b.reload},function(a){Q();a.items?(R(),X(a.items,!1)):t.hide();a.err?c.reject(a):c.resolve(a)})}catch(d){console.log("sS: "+d.message),c.reject({err:d.message})}return c.promise()},ub=function(a,b){var c=C();try{W(),sendMessage({method:"exportToJson",ids:a,options:b},function(a){R();Q();t.hide();a.json?c.resolve(a.json):c.reject()})}catch(d){console.log("eJ: "+
d.message),c.reject({})}return c.promise()},Ma=function(a,b){var c=C();try{W(),sendMessage({method:"importFromJson",json:a,reload:b.reload},function(a){Q();a.reload?window.setTimeout(function(){rea.page.reload()},500):a.items?(R(),X(a.items,!0)):t.hide();a.err?c.reject(a):c.resolve(a)})}catch(d){console.log("sS: "+d.message),c.reject({err:d.message})}return c.promise()},Ib=function(a,b,c){var d=C();try{c.auto_save||W(),sendMessage({method:"saveExternal",uuid:a,code:b,mimetype:c.mimetype,url:c.url,
auto_save:c.auto_save},function(a){c.auto_save||(R(),Q());a=a||{};a.items?X(a.items,!0):t.hide();d.resolve(a)})}catch(g){console.log("sS: "+g.message),d.reject({err:g.message})}return d.promise()},Pa=function(a,b,c){var d=C();void 0===c.reload&&(c.reload=!0);try{c.auto_save||W(),sendMessage({method:"saveScript",uuid:a,code:b,clean:c.clean,force:c.force,new_script:c.new_script,auto_save:c.auto_save,lastModTime:c.lastModTime,reload:c.reload},function(a){c.auto_save||(R(),Q());a=a||{};a.items?X(a.items,
!0):t.hide();!b&&c.reload&&t.hide();d.resolve(a)})}catch(g){console.log("sS: "+g.message),d.reject({err:g.message})}return d.promise()},xa=function(a,b,c){var d=C();try{W(),sendMessage({method:"setOption",name:a,value:b},function(a){Q();R();v=a.options||v;!c&&a.items?X(a.items,!1):t.hide();d.resolve(a)})}catch(g){console.log("sO: "+g.message),d.reject({err:g.message})}return d.promise()},qb=function(a,b,c){var d=C();try{W(),sendMessage({method:"buttonPress",name:a,data:b},function(a){Q();!c&&a.items?
(R(),X(a.items,!1)):t.hide();d.resolve(a)})}catch(f){console.log("sO: "+f.message),d.reject({err:f.message})}return d.promise()},la=function(a,b){W();sendMessage({method:"loadTree",complete:a.complete,uuid:a.uuid,url:a.url,referrer:a.referrer,layout:a.layout,filter:a.filter},function(a){Q();v=a.options||v;!Fa&&a.xhr&&(Fa=Registry.get("xmlhttprequest"),Fa.setConfig(a.xhr));a.i18n&&d.setLocale(a.i18n);a.items?a.begging&&M.push(function(){window.setTimeout(function(){ab(a.begging)},100)}):a.error?alert(a.error):
confirm(d.getOriginalMessage("An_internal_error_occured_Do_you_want_to_visit_the_forum_"))&&(window.location.href="https://www.tampermonkey.net/bug");b(a)})},Pb=function(a,b,c){la({referrer:"options.scripts.userscripts.matches",uuid:a,filter:b},function(a){t.hide();c(a.items[0])})},gb=function(){la({referrer:"options.scripts"},function(a){a.items?X(a.items,!0):t.hide()})},ia=function(a,b,c){void 0==c&&(c=!0);try{a={method:"modifyScriptOptions",uuid:a,reload:c};for(var e in b)b.hasOwnProperty(e)&&
(a[e]=b[e]);W();sendMessage(a,function(a){Q();v=a.options||v;a.i18n&&d.setLocale(a.i18n);R();a.items?X(a.items,!0):t.hide()})}catch(f){console.log("mSo: "+f.message)}},Qa=function(a,b,c,d){void 0===d&&(d=!0);try{a={method:"modifyNativeScript",nid:a,actionid:b,value:c,reload:d},W(),sendMessage(a,function(a){Q();R();a.items?X(a.items,!0):t.hide()})}catch(f){console.log("mSo: "+f.message)}},db=function(a,b,c){try{a={method:"saveStorageKey",uuid:a,key:b,value:c,id:"options"},W(),sendMessage(a,function(){Q();
R();t.hide()})}catch(d){console.log("sSk: "+d.message)}},wb=function(a,b,c){try{a={method:"download",details:{url:a,name:b,saveAs:!0},id:"options"},W(),sendMessage(a,function(){Q();R();t.hide();c()})}catch(d){console.log("dDU: "+d.message)}},Gb=function(a,b){try{W(),sendMessage({method:"buttonPress",name:"externals_delete",scriptuid:a,safe_url:b},function(a){Q();R();a.items?X(a.items,!1):t.hide()})}catch(c){console.log("dEx: "+c.message)}},Jb=function(a,b){try{sendMessage({method:"buttonPress",name:"run_script_updates",
scriptuid:a},function(a){R();b&&b(a.updatable)})}catch(c){console.log("rSu: "+c.message)}},Kb=function(a,b,c){try{sendMessage({method:"reportAnIssue",uuid:a,to:b},function(){c&&c()})}catch(d){console.log("rRi: "+d.message)}},lb={};rea.extension.onMessage.addListener(function(a,b,c){if("updateOptions"==a.method)v=a.options||v,X(a.items,!1),c({});else if("confirm"==a.method)u.confirm(a.msg,function(a){c({confirm:a})});else if("showMsg"==a.method)u.alert(a.msg),c({});else if("status"==a.method)Ka(a.options),
c({});else return!1;return!0});(function(){la({referrer:"options",layout:!0},function(a){Ab();Da.applyTheme(a.layout);if(a.options&&a.options.layout_user_css&&"reset"!==ca.layout){var b=document.createElement("style");b.innerHTML=a.options.layout_user_css;(document.head||document.body||document.documentElement||document).appendChild(b)}a.items?X(a.items,!1):t.hide()})})()})});
