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