'use strict';var trup,init,sycl,cfgo,uris,dast,perm,blak,scbr,scma,exts,down;
Registry.require("promise statistics convert xmlhttprequest downloads tools storage uri compat parser layout helper syncinfo notify asker i18n native".split(" "),function(){var n=Registry.log,p=rea.FEATURES,ka=function(){var q=[],d=!0,e=function(e,q,c){var a={title:e.join("\n\n")};q.path=rea.extension.getURL("images/icon"+(q.frag?"_"+q.frag:"")+".png");n.warn(e.join("\n"));rea.browserAction.setIcon({path:q.path});rea.browserAction.setTitle(a);q=function(a,g,c){a={name:"1",sub_menu_item:!0,pos:"left",
items:[]};a.items.push({name:e[0],image:"info"});1<e.length&&a.items.push({name:e[1]});c({items:[a],options:{enabled:!1}})};c||rea.extension.onMessage.addListener(q)};return{run:function(){try{Registry.verify("5946").length&&(d=!1,e(["Tampermonkey detected that browser is caching some outdated code parts.","In order to avoid unexpected behavior TM will be kept paused until your browser was restarted."],{frag:"paused"}))}catch(q){d=!1,n.error(q.message)}if("chromeStorage"==p.DB.USE&&!p.DB.NO_WARNING){var h=
function(){if(!r)return window.setTimeout(h,2E3);r.isWorking().fail(function(){confirm("Tampermonkey detected that the extension storage is unreliable!\n\nUnfortunately this means that all your settings and userscripts are inaccessible at the moment.\n\nDo you want to visit the FAQ entry that explains how to recover from that?")&&rea.tabs.create({url:"https://www.tampermonkey.net/faq#Q206"},function(){});e(["Tampermonkey detected that the extension storage is unreliable!"],{frag:"paused"},!0)})};
window.setTimeout(h,1E3)}return d},pause:e,setWarning:function(e,d,c){q.push({text:e,description:d,url:c})},getWarnings:function(){return q}}}();if(ka.run()){var m=Registry.get("promise"),w=Registry.get("helper"),za=Registry.get("tools"),L=Registry.get("statistics"),r=Registry.get("storage"),S=Registry.get("notify"),X=Registry.get("asker"),Q=Registry.get("native"),la=Registry.get("permission"),ma=Registry.get("layout"),A=Registry.get("uri"),d=Registry.get("i18n"),K=Registry.get("downloads"),M=za.cache,
J=Registry.get("convert");uris=A;down=K;perm=la;dast=r;var Aa=w.createUUID(),ga={};n.debug("Starting background fred @"+Aa);M.create("rundata").setOptions({timeout:5,check_interval:10,retimeout_on_get:!0}).init();M.create("regexp").setOptions({timeout:300,check_interval:120,retimeout_on_get:!0}).init();var Ga=function(){var q=m(),d,e,h=rea.extension.manifest.version,l=r.getSchemaVersion(),c=l;r.getVersion("0.0.0.0").then(function(a){e=a;d=C.versionCmp(h,e)==C.versionCmp.eNEWER;return r.isWiped()}).then(function(a){!d&&
a&&(a=["Tampermonkey detected inconsistencies that indicate that your browser wiped the extension database!","You can continue to use Tampermonkey normally, but your settings and scripts might be lost. Click here to get more information.","https://www.tampermonkey.net/faq.php#Q207"],n.warn(a.join("\n")),ka.setWarning.apply(this,a))}).always(function(){var a=[],b=0,g=function(){if(b<a.length){var k=a[b].schema;a[b].cond(k)?a[b].fn().done(function(){k&&(n.log("Converted database from",c,"to",k),c=k);
b++;g()}).fail(function(){q.reject()}):(b++,g())}},k=function(){n.warn("Incognito mode detected. Database conversion can only be done in non-incognito mode! Stopping now...");ka.pause(["Tampermonkey needs to convert its database but this can't be done in incogonito mode!","Please open a non-incognito mode window and/or restart your browser."],{frag:"paused"})},a=[{cond:function(){return d&&!p.RUNTIME.FIREFOX&&!p.RUNTIME.EDGE&&"chromeStorage"==p.DB.USE&&!r.getValue(p.CONSTANTS.STORAGE.LEGACY_VERSION)&&
C.versionCmp("3.5.3603",e)==C.versionCmp.eNEWER},fn:function(){var a=m();rea.extension.inIncognitoContext?(k(),a.reject()):(n.log("Update database..."),c="3.5.3603",r.migrate("sql","chromeStorage").done(function(){n.log("Copied config for default usage of chrome storage");a.resolve()}));return a.promise()}},{cond:function(){return d&&C.versionCmp("3.6.3650",c)==C.versionCmp.eNEWER&&C.versionCmp("3.5.3650",e)==C.versionCmp.eNEWER},fn:function(){var a=m();if(rea.extension.inIncognitoContext)k(),a.reject();
else{c="3.6.3650";var b=[];[{o:"TM_config",n:p.CONSTANTS.STORAGE.CONFIG},{o:"TM_update_check",n:p.CONSTANTS.STORAGE.UPDATE},{o:"TM_version"},{o:"TM_unload_ts"}].forEach(function(a){if(a.n){var g=r.getValue(a.o);void 0!==g&&b.push(r.setValue(a.n,g))}b.push(r.deleteValue(a.o))});var g=/@re$/,d=[];r.listValues().forEach(function(a){-1!=a.search(g)&&(a=a.replace(g,""),d.push(a))});d.forEach(function(a){var g=r.getValue(a+"@st"),c=r.getValue(a),k=r.getValue(a+"@re"),v=r.getValue(a+"@source"),e=z.getUidByName(a)||
w.createUUID();b.push(r.deleteValue(a+"@st"));b.push(r.deleteValue(a));b.push(r.deleteValue(a+"@re"));b.push(r.deleteValue(a+"@source"));c&&k&&v?(b.push(r.setValue(p.CONSTANTS.PREFIX.SCRIPT_UID+e,a)),b.push(r.setValue(p.CONSTANTS.PREFIX.COND+e,k)),b.push(r.setValue(p.CONSTANTS.PREFIX.STORE+e,g)),b.push(r.setValue(p.CONSTANTS.PREFIX.SCRIPT+e,v)),b.push(r.setValue(p.CONSTANTS.PREFIX.META+e,c))):n.warn("invalid script entry",{source:v,meta:c,cond:k})});g=/@st$/;r.listValues().forEach(function(a){-1!=
a.search(g)&&b.push(r.deleteValue(a))});m.when(b).done(function(){n.log("Converted database from",e,"to",c);a.resolve()})}return a.promise()}},{schema:"3.7.0",cond:function(a){return C.versionCmp(a,c)==C.versionCmp.eNEWER},fn:function(){var a=m();if(rea.extension.inIncognitoContext)k(),a.reject();else{var b=[],g=new RegExp("^"+p.CONSTANTS.PREFIX.META);r.listValues().forEach(function(a){if(-1!=a.search(g)){var c=r.getValue(a);c.options&&c.options.override&&!c.options.override.orig_run_at&&(c.options.override.orig_run_at=
c.options.run_at||"document-idle",c.options.run_at=null,b.push(r.setValue(a,c)))}});m.when(b).done(function(){a.resolve()})}return a.promise()}},{schema:"4526",cond:function(a){return d&&p.RUNTIME.SAFARI&&"chromeStorage"==p.DB.USE&&C.versionCmp(a,c)==C.versionCmp.eNEWER},fn:function(){var a=m();if(rea.extension.inIncognitoContext)k(),a.reject();else{n.log("Update database...");var b=r.migrate("localStorage","chromeStorage").done(function(){n.log("Copied config for default usage of setting storage")});
a.consume(b)}return a.promise()}},{schema:"4871",cond:function(a){return d&&C.versionCmp(a,c)==C.versionCmp.eNEWER},fn:function(){var a=m(),b,g,c=r.getValue(p.CONSTANTS.STORAGE.CONFIG);c&&c.scriptTemplate&&(g=f.getDefaults())&&(b=g.script_templates)&&b[0]&&b[0].value&&(b[0].value=c.scriptTemplate,delete c.scriptTemplate,r.setValue(p.CONSTANTS.STORAGE.CONFIG,c));a.resolve();return a.promise()}},{schema:"5465",cond:function(a){return C.versionCmp(a,c)==C.versionCmp.eNEWER},fn:function(){var a=m();if(rea.extension.inIncognitoContext)k(),
a.reject();else{var b=r.getValue(p.CONSTANTS.STORAGE.CONFIG);b&&1==b.sync_version&&(b.sync_enabled=!1,r.setValue(p.CONSTANTS.STORAGE.CONFIG,b));a.resolve()}return a.promise()}},{cond:function(){return d||C.versionCmp(c,l)==C.versionCmp.eNEWER},fn:function(){var a=m();r.setVersion(h,c).done(function(){a.resolve()});return a.promise()}},{cond:function(){return d},fn:function(){n.log("First run of version "+h+"!");ha.scheduleNotification(e,"0.0.0.0"==e);return m.Pledge()}},{cond:function(){return!0},
fn:function(){var a=m();q.resolve();window.setTimeout(a.resolve,p.MISC.TIMEOUT);return a.promise()}}];g()});return q.promise()},Z=function(){return{get:function(d,u){var e=(0==d)+"#"+u,h=M.items.rundata.getj(e);if(h)h=h.oldret;else{var h=[],l=[],c=[],a={};if(u)for(var b=x.determineScriptsToRun(u,!0),g=0;g<b.length;g++){var k=b[g];x.isContexter(k)||0!=d&&(!0===k.options.noframes||null===k.options.noframes&&!0===k.options.override.orig_noframes)||(k.evilness&&k.evilness>=Math.min(G.SEVERITY_MAX,f.values.script_blacklist_severity)?
c.push(k):k.enabled?(a[k.uuid]=u,h.push(k)):l.push(k))}h={runners:h,disabled:l,evilness:c,script_map:a};u&&M.items.rundata.setj(e,{frameId:d,oldret:h})}return h},answer:function(d,u){var e=w.select(d,function(a){return a}),h=[{m:"native",t:[K.staticVars.DEFAULT,K.staticVars.NATIVE]},{m:"disabled",t:[K.staticVars.OFF]},{m:"browser",t:[K.staticVars.CHROME]}].filter(function(a){if(-1!=a.t.indexOf(f.values.downloads_mode))return!0}).map(function(a){return a.m})[0]||"disabled",l=rea.extension.inIncognitoContext,
c=!l&&"off"!=f.values.external_connect&&x.validUrl(u,Ca.externally_connectable_reg);return{scripts:e,contexters:pa.getContexterCount(),raw:{},external_connect:c,inIncognitoContext:l,downloadMode:h,enforce_strict_mode:"on"==f.values.runtime_strict_mode,statistics:L.isActive("api"),measure_scripts:f.values.debug,logLevel:f.values.logLevel,version:rea.extension.manifest.version}},getContexters:function(d,f){for(var e=[],h=x.determineScriptsToRun(f),l=0;l<h.length;l++){var c=h[l];c.enabled&&(0==d||!0!==
c.options.noframes&&(null!==c.options.noframes||!0!==c.options.override.orig_noframes))&&x.isContexter(c)&&e.push(c)}return e}}}(),E=function(){var d={},u=1,e=u++,h=u++,l=u++,c=u++,a=u++,b=u++,g=u++,k=function(){var a={frames:{0:{state:e}},tabs:{reset_ts:Date.now()},scripts:{},urls:{},maps:{},contexts:{onUnload:{}},stats:{running:0,disabled:0},extra:{}};Object.defineProperties(a.urls,{length:{value:0,enumerable:!1,writable:!0,configurable:!0}});return a},v={updateStats:function(a,b,c,g){d[a].stats.running+=
c;d[a].stats.disabled+=g;d[a].contexts.onUnload[b]=d[a].contexts.onUnload[b]||[];d[a].contexts.onUnload[b].push(function(){d[a].stats.running-=c;d[a].stats.disabled-=g});d[a].tabs.ts=Date.now()},updateMaps:function(a,b,c){var g=1,k=function(b,c){var k=1===g;void 0===d[a].maps[c]&&k&&(d[a].maps[c]={count:0,all_time:0,urls:[]});k&&(d[a].maps[c].urls.push(b),d[a].maps[c].all_time++);d[a].maps[c].count+=g};w.each(c,k);d[a].contexts.onUnload[b]=d[a].contexts.onUnload[b]||[];d[a].contexts.onUnload[b].push(function(){d[a]&&
(g=-1,w.each(c,k))})},updateUrls:function(a,b,c){var g=function(g){1===g&&(void 0===d[a].urls[c]?d[a].urls[c]={frameId:b,count:0}:0===b&&(d[a].urls[c].frameId=b));d[a].urls[c].count+=g;d[a].urls.length=-1};g(1);d[a].contexts.onUnload[b]=d[a].contexts.onUnload[b]||[];d[a].contexts.onUnload[b].push(function(){d[a]&&g(-1)})},determine:function(a,b,c){var g;T.isAllowed(c)?g=Z.get(b,c):(n.debug("This URL is filtered by the security settings:",c,"-> Do nothing!"),E.set.forbidden(a,b),g={runners:[],disabled:[],
evilness:[],script_map:{}});d[a].scripts[c]=g;g.runners.forEach(function(c){c.webRequest&&ia.scripts.set(a,b,c.uuid,c.webRequest)});return g.runners.length},run:function(a,b,c,g,k){a=[];for(b=0;b<g.length;b++)a.push(Ea.bundle({url:c},g[b]));var d;m.when(a).always(function(a){k?k(a):d=a});return d}},t={},y={},D={},F={},B={listeners:{once:{whenReady:function(a,b){if(!d[a]||d[a].frames[0].state<l)B.listeners.once.onReady(a,b);else b()},onReady:function(a,b){var c=function(a){B.listeners.remove.onCommited(g);
B.listeners.remove.onCompleted(k);a&&b()},g=B.listeners.add.onCommited(function(b){b===a&&c(!0)}),k=B.listeners.add.onCompleted(function(b){b===a&&c(!0)})}},add:{onReset:function(a){var b=w.createUUID();t[b]=a;return b},onCommited:function(a){var b=w.createUUID();y[b]=a;return b},onCompleted:function(a){var b=w.createUUID();D[b]=a;return b},onRemoved:function(a){var b=w.createUUID();F[b]=a;return b}},remove:function(){return{onReset:function(a){delete t[a]},onCommited:function(a){delete y[a]},onCompleted:function(a){delete D[a]},
onRemoved:function(a){delete F[a]}}}()},events:{reset:function(a,b){var c;p.RUNTIME.FAST_EXEC_SUPPORT&&(c=d[a])&&Object.keys(c.frames).forEach(function(b){B.events.clean(a,b)});c=d[a]=k();c.frames[0].state=e;w.each(t,function(c){c&&c(a,b)})},response:function(a,b,c){if(f.values.enabled){var g=d[a]=d[a]||k(),t=g.frames[b]=g.frames[b]||{},y=t.state||e;0===b&&(g.tabs.response_ts=Date.now());c=A.woHash(c);y<h&&(v.determine(a,b,c),t.state=h);return(a=g.scripts[c])?a.runners.length:0}},commited:function(a,
b,c){if(f.values.enabled){var g=A.parse(c);if("http:"===g.protocol||"https:"===g.protocol||"file:"===g.protocol){var g=d[a]=d[a]||k(),g=g.frames[b]=g.frames[b]||{},t=g.state||e;t>=l||(g.state=l,t<h&&(c=A.woHash(c),v.determine(a,b,c)),w.each(y,function(b){b&&b(a)}))}}},loading:function(a,b,g){if(f.values.enabled){var t=A.parse(g);if(("http:"===t.protocol||"https:"===t.protocol||"file:"===t.protocol)&&0===b&&"file:"===t.protocol){t=d[a]=d[a]||k();t.frames[b]=t.frames[b]||{};var y=t.frames[b].state||
e;y>=c||(t.frames[b].state=c,y<h&&(g=A.woHash(g),v.determine(a,b,g)))}}},run:function(b,c,g,t,e){if(f.values.enabled){var y=0===c||p.RUNTIME.FAST_EXEC_SUPPORT?c:g,F=d[b]=d[b]||k();F.frames[y]=F.frames[y]||{};var h=A.woHash(t),D=F.scripts[h];if(!D&&(n.debug("tv: lazy init @ events.run("+b+", "+c+", "+g+", "+t+")"),v.determine(b,c,h),D=F.scripts[h],!D)){n.warn("tv: no script run info for tab "+b+" @ "+h,n.D?F.scripts:"");return}g=F.frames[y].state;F.frames[y].state=a;g!=a&&(v.updateMaps(b,y,D.script_map),
v.updateUrls(b,y,h),v.updateStats(b,y,D.runners.length,D.disabled.length));return v.run(b,c,h,D.runners,e?function(a){B.events.clean(b,y,t);e(a)}:null)}},clean:function(a,b,c){if(f.values.enabled){var g,k;if(g=d[a])c&&(c=A.woHash(c),delete g.scripts[c]),(k=E.get.objurl(a,b))&&URL.revokeObjectURL(k)}},complete:function(c,g,t){t=A.parse(t);if(f.values.enabled&&("http:"===t.protocol||"https:"===t.protocol||"file:"===t.protocol)){if(0===g){var v=d[c]=d[c]||k();v.frames[g]=v.frames[g]||{};var y=v.frames[g].state||
e;v.frames[g].state=b;if(!E.get.empty(c)&&E.get.stats(c).running){if(y<a){n.warn("tv: no script run info!");return}"file:"===t.protocol?window.setTimeout(function(){rea.tabs.sendMessage(c,{method:"onLoad",frameId:g},function(){})},500):rea.tabs.sendMessage(c,{method:"onLoad",frameId:g},function(){})}}w.each(D,function(a){a&&a(c)})}},unload:function(a,b,c){c=0===b||p.RUNTIME.FAST_EXEC_SUPPORT?b:c;p.RUNTIME.FAST_EXEC_SUPPORT&&B.events.clean(a,b);a=d[a]=d[a]||k();a.frames[c]=a.frames[c]||{};a.frames[c].state=
g;if(a.contexts.onUnload[c]){for(b=0;b<a.contexts.onUnload[c].length;b++)a.contexts.onUnload[c][b]();a.contexts.onUnload[c]=[]}},remove:function(a){var b;p.RUNTIME.FAST_EXEC_SUPPORT&&(b=d[a])&&Object.keys(b.frames).forEach(function(b){B.events.clean(a,b)});delete d[a];w.each(F,function(b){b&&b(a)})}},set:{extra:function(a,b,c,g){a=d[a]=d[a]||k();null===b?a.extra[c]=g:(a.extra[c]=a.extra[c]||{},a.extra[c][b]=g)},objurl:function(a,b,c){B.set.extra(a,b,"objurl",c)},blocker:function(a){B.set.extra(a,
null,"blocker",!0)},forbidden:function(a,b){0===b&&B.set.extra(a,null,"forbidden",!0)},requests:function(a,b,c,g){a=d[a]=d[a]||k();b=a.frames[b]=a.frames[b]||{};(b.requests=b.requests||{})[c]=g}},get:{extra:function(a,b,c,g,k){void 0===g&&(g=null);a=(d[a]?d[a].extra:{})[c];null!==b&&a&&k&&delete a[b];return a||g},empty:function(a){var b=!0;if(d[a]&&0!=d[a].urls.length){if(-1==d[a].urls.length)return d[a].urls.length=0,w.each(d[a].urls,function(b,c){"length"!==c&&0<b.count&&d[a].urls.length++}),B.get.empty(a);
b=!1}return b},urls:function(a,b){var c;return b?(c=d[a].maps[b])?c.urls:[]:(c=d[a])?c.urls:{}},history:function(a){return d[a].maps},stats:function(a,b){var c={};d[a]&&(c.running=d[a].stats.running,c.disabled=d[a].stats.disabled,b&&(c.unique=0,Object.keys(d[a].maps).forEach(function(b){0<d[a].maps[b].count&&c.unique++})));return c},tabs:function(){var a={};w.each(d,function(b,c){a[c]={ts:b.response_ts}});return a},objurl:function(a,b){return B.get.extra(a,b,"objurl",null,!0)},blocker:function(a){return B.get.extra(a,
null,"blocker")},forbidden:function(a){return B.get.extra(a,null,"forbidden")},requests:function(a,b){return d[a]&&d[a].frames[b]?d[a].frames[b].requests:null}}};return B}(),qa=function(){var d={};return{get:function(f,e){d[f]||(d[f]={});d[f][e]||(d[f][e]={});return d[f][e]},getAll:function(f){var e={};Object.keys(d).forEach(function(h){e[h]={};e[h]=d[h][f]});return e},set:function(f,e,h){d[f]||(d[f]={});var l={};h&&Object.keys(h).forEach(function(c){l[c]=h[c]});d[f][e]=l},cleanTab:function(f){delete d[f]}}}(),
ra=function(){return{isScriptUrl:function(d,f){if(!d||-1!=d.search(/\#bypass=true/)||-1!=d.search(p.REQUESTS.GET_INTERNAL_PAGE_REGEXP())||"data:"===d.substr(0,5))return!1;var e=f?d:d.split(/[\?#$]/)[0],h=-1!=e.search(/.+\.user\.(js\#|js\?|js$)/)||-1!=e.search(/.+\.tamper\.(js\#|js\?|js$)/);return h?!(-1!=e.search(/^htt[ps]{1,2}:\/\/code\.google\.com/)||-1!=e.search(/^htt[ps]{1,2}:\/\/(github|gitlab)\.com/)&&!x.determineOriginOfUrl(e)||-1!=e.search(/^htt[ps]{1,2}:\/\/bitbucket\.org/)&&!x.determineOriginOfUrl(e)):
h}}}(),T=function(){return{init:function(){var d=function(){M.items.regexp.remove("PageFilter")};f.addChangeListener("forbiddenPages",d);f.addChangeListener("page_whitelist",d);f.addChangeListener("page_filter_mode",d)},isAllowed:function(d){var u=!1,e=!1,h=N.getSyncRemoteDomains().map(function(a){return"*://"+a+"/*"}),h=f.values.forbiddenPages.concat(h),l=0<h.length,c=0<f.values.page_whitelist.length;switch(f.values.page_filter_mode){case "black":e=l;break;case "off":break;case "white":u=c;break;
default:u=c,e=l}(l=M.items.regexp.get("PageFilter"))||(l=x.regexify({inc:u?f.values.page_whitelist:void 0,exc:e?h:void 0}),M.items.regexp.set("PageFilter",l));return!e&&!u||x.validUrl(d,l)}}}(),G=function(){var q=function(d,h){var f=!1;if(h.length)return(f="/"==h.substr(0,1)?x.matchUrl(d,x.convertToRegExp(h)):-1!=d.search(h))&&n.debug('black: entry "'+h+'" matched'),f},u={SEVERITY_MAX:10,SEVERITY_MANUALLY_DEFINED:11,SEVERITY_FOISTED_SCRIPT:12,init:function(){var d=m(),h=function(){"server"===f.values.script_blacklist_type&&
window.setTimeout(u.checkUpdate,2E4)};h();f.addChangeListener("script_blacklist_type",h);d.resolve();return d.promise()},getWarningsFor:function(e){var h=[];e&&w.each(f.values.script_blacklist_server,function(f){if(f){var c;w.each(f.rules,function(a){c|=q(e,a);return 1!=c});if(c)if(f.reasons){var a=Object.keys(f.reasons),b,g;void 0!==(b=d.getBestLocale(a))&&(g=a[b]);h.push(f.reasons[g||"en"])}else f.reason&&h.push(f.reason)}});return h},getEvilnessOf:function(d){if("off"===f.values.script_blacklist_type)return!1;
if(!d)return 0;var h=!1,l=0;w.each(f.values.require_blacklist,function(c){h|=q(d,c);return 1!=h});h?l=u.SEVERITY_MANUALLY_DEFINED:"server"===f.values.script_blacklist_type&&w.each(f.values.script_blacklist_server,function(c){if(c&&(w.each(c.rules,function(a){h|=q(d,a);return 1!=h}),h))return l=c.severity,!1});return Number(l)},checkUpdate:function(d){var h=m(),q=aa.getConfig(),c;if(d||6048E5<Date.now()-q.black.last){var a=function(a,c){var d=m();ba.internal({method:"GET",url:a,nocache:c,retries:p.XMLHTTPREQUEST.RETRIES,
overrideMimeType:"text/plain; charset=x-user-defined"},{ondone:function(a){d.resolve(a)}});return d.promise()};a("https://blacklist.tampermonkey.net/get.php?version=get").then(function(b){if(4==b.readyState&&200==b.status){try{c=JSON.parse(b.responseText).version}catch(g){n.warn("black: unable to parse version response! "+b.responseText)}n.info("black: local version: "+q.black.version+" remote: "+c);if(c>q.black.version||d)return a("https://blacklist.tampermonkey.net/get.php",!0)}}).then(function(a){if(a&&
4==a.readyState&&200==a.status)try{var c=JSON.parse(a.responseText);c&&c.blacklist&&1==c.version&&(f.values.script_blacklist_server=c.blacklist);n.info("black: updated blacklist to ",c)}catch(d){n.warn("black: blacklist update failed! ",a.responseText)}}).always(function(){q=aa.getConfig();q.black.last=Date.now();q.black.version=c||q.black.version;aa.setConfig(q);h.resolve()})}else h.resolve();return h.promise()}};return u}();blak=G;var Ia=function(){for(var d=[],f=[],e=0;e<d.length;e++){var h=Registry.getRaw("system/"+
d[e]+".tamper.js");h&&f.push(h)}return f},N=function(){var q=0,u=[],e={to:null,force:null,t:0},h={},l=za.createQueue(1),c={},a=function(a){return l.add(function(){n.debug("sync: import",a.uuid,a.name,a.url);var b={imported:f.values.sync_type},c={},g;for(g in D.SYNCED)!0===D.SYNCED[g]&&(c[g]=a.options[g]);var d={uuid:a.uuid,ask:!1,internal:!0,sync:b,force_meta:{lastModified:a.lastModified,fileURL:a.url},force_options:c},k={silent_fail:!0};return H.caps.syncsSource?H.getSource(a.uuid).then(function(a){return x.installFromSource(a,
d,k)}):x.installFromUrl(a.url,d,k)})},b=function(a,b){return l.add(function(){if(!H.caps.syncsSource){var c;if(!a.url||!(c=A.parse(a.url))||!c.protocol.match(/https?:/))return n.debug("sync: skip export due to missing URL",a.name,a.url),m.Pledge(!1)}n.debug("sync: export",a.name,a.url);return H.setMeta(a,{lastModified:a.lastModified}).then(function(){if(H.setSource&&b)return H.setSource(a.uuid,b)}).then(function(){return!0})})},g=function(a){var b=a.downloadURL?a.downloadURL.split("#")[0]:null,c=
a.fileURL?a.fileURL.split("#")[0]:null,g=w.select([c,b],function(a){if(!a||"file:"!==A.parse(a).protocol)return a})[0],b={uuid:a.uuid,name:a.name,options:{},durl:b,furl:c,url:g,lastModified:a.lastModified||a.lastUpdated},d;for(d in D.SYNCED)!0===D.SYNCED[d]&&null!==a.options[d]&&(b.options[d]=a.options[d]);return b},k=function(){var a=[];z.getUidList().forEach(function(b){b=z.getByUid(b);if(b.script&&b.cond){var c=g(b.script);c.lastModified||Registry.isDevVersion("test")?b.script.evilness&&b.script.evilness>=
Math.min(G.SEVERITY_MAX,f.values.script_blacklist_severity)?n.warn("sync: ignore evil script",b.script):a.push(c):n.warn("sync: script without updated/modified timestamps found",b.script)}});return a},v=function(g){if(D.enabled)if(0<q)g&&D.addSyncDoneCallback(function(a){a&&D.sync(50,g)});else{q++;var t=null,v=null,y=0,e=0,l=!0,p=function(a){if(a)for(var b=0;b<v.length;b++)if(v[b].uuid==a)return v[b];return null},r=function(a){if(!a)return null;for(var b=0;b<t.length;b++)if(t[b].uuid==a)return t[b]},
Ha=function(a,b,c){return c?Math.floor(a/c)*c>Math.floor(b/c)*c:a>b},w=function(a,b,c){return c?Math.floor(a/c)*c<Math.floor(b/c)*c:a<b},A=function(a,b,c){return c?Math.floor(a/c)*c!=Math.floor(b/c)*c:a!=b};O.all("status",{key:"sync_status",class:"information",title:d.getMessage("Script_Sync"),text:d.getMessage("Sync_is_running"),timeout:9E5});return m.Pledge().then(function(){t=k();return H.list().done(function(a){v=a}).fail(function(){n.warn("sync: unable to get remotelist!")})}).then(function(){var b=
v.map(function(b){var g,k=r(b.uuid),t,v;if(k){if(!b.lastModified&&f.values.sync_type==H.types.eCHROMESYNC)for(var e in D.SYNCED)if(!0===D.SYNCED[e]&&k.options[e]!=b.options[e]){n.debug("sync: importable change detected!",b.name,"key:",e,b);t=!0;break}b.lastModified&&w(k.lastModified,b.lastModified,b.precision)&&(v=b.lastModified,t=!0,n.debug("sync: importable change detected!",b.name,"local ts:",new Date(k.lastModified),"remote ts:",new Date(b.lastModified),b))}else(g=c[b.uuid])&&b.lastModified&&
w(g.lastModified,b.lastModified,b.precision)&&(v=b.lastModified,t=!0,n.debug("sync: changed cache entry detected!",b.name,"local ts:",new Date(g.lastModified),"remote ts:",new Date(b.lastModified),b));if(!k&&!g||t)return function(){return m.Pledge().then(function(){return H.caps.specialMeta?H.getMeta(b.uuid):m.Pledge(b)}).then(function(b){if(b){var e;if(k)if(b.options.removed)y++,n.debug("sync: remove local script",b.uuid,b.name,b.url),x.doRemove(k.uuid,!1);else{if(t){A(v,b.lastModified,b.precision)&&
(b.lastModified&&n.warn("sync: list and meta data lastModified differ, this will cause extra traffic!","file ts:",new Date(v),"meta ts:",new Date(b.lastModified),b),b.lastModified=v);y++;n.debug("sync: update local script",b.uuid,b.name,b.url);var F=z.getByUid(k.uuid);if(F.script&&F.cond){for(e in D.SYNCED)!0===D.SYNCED[e]&&(F.script.options[e]=b.options[e]);F.script.lastModified=b.lastModified;return m.Pledge().then(function(){if(H.caps.syncsSource){var a=m();H.getSource(b.uuid,F.script.textContent).done(function(a){F.script.textContent=
a}).fail(function(){n.warn("sync: getting source of",b.uuid,"failed",b)}).always(a.resolve);return a.promise()}}).then(function(){return x.doModify(F.script.uuid,F.script,!1)})}n.warn(d.getMessage("fatal_error")+"("+k.name+")!!!")}}else if(k||b.options.removed)!g&&b.options.removed&&(c[b.uuid]=b);else if(e=m(),b.url&&h[b.url]||b.uuid&&h[b.uuid])n.warn("sync: skip previously failed import",b);else return a(b).done(function(a){a?y++:(n.warn("sync: unable to import",b),h[b.url]=!0,h[b.uuid]=!0)}).fail(function(){n.warn("sync: unable to load",
b);h[b.url]=!0;h[b.uuid]=!0}).always(e.resolve),e.promise()}})}}).filter(function(a){return a});return m.onebyone(b)}).then(function(){y&&(x.reorderScripts(),O.all("status",{key:"sync",class:"information",title:d.getMessage("Script_Sync"),text:d.getMessage("0count0_changes_imported",y),timeout:1E4}));t=k();return m.Pledge()}).then(function(){for(var a=[],c=0;c<t.length;c++)a.push(function(){var a=t[c],g,d;if(!H.caps.syncsSource&&!a.url)return m.Pledge();var k=p(a.uuid);if(k){if(!k.lastModified||Ha(a.lastModified,
k.lastModified,k.precision))g=!0,n.debug("sync: exportable change detected!",a.name,"remote ts:",new Date(k.lastModified),"local ts:",new Date(a.lastModified),a)}else n.debug("sync: export because remotely missing!",a.name,"local ts:",new Date(a.lastModified),a);return!k||g||H.caps.syncsSource&&!k.source?(H.caps.syncsSource&&(g=z.getByUid(a.uuid),g.script&&g.cond&&(d=g.script.textContent)),b(a,d).then(function(a){a&&e++})):m.Pledge()}());return m.when(a)}).fail(function(){l=!1}).done(function(){l=
!0}).always(function(){n.debug("sync: finished");if(0==--q){O.all("status",{key:"sync_status",class:"information",title:d.getMessage("Script_Sync"),text:d.getMessage("Sync_finished"),timeout:15E3});e&&O.all("status",{key:"sync",class:"information",title:d.getMessage("Script_Sync"),text:d.getMessage("0count0_changes_exported",e),timeout:5E3});for(var a=l;u.length;)u.shift()(a)}})}},t=function(){D.enabled&&D.sync(500,!0)},y=null,D={enabled:!1,SYNCED:{comment:!0},configChangeListener:function(){y||(y=
window.setTimeout(function(){y=null;D.init().done(function(){D.enabled&&D.sync(3E3)})},3E3))},init:function(){var a=m();D.enabled=!1;(function(){return f.values.sync_enabled&&f.values.sync_type?H.init(f.values.sync_type,{url:f.values.cloud_url,basic_auth:J.Base64.encode(f.values.cloud_user+":"+f.values.cloud_pass)}).done(function(a){D.enabled=a;D.enabled?H.addChangeListener(t):n.warn("sync: init failed!")}).fail(function(){n.warn("sync: init failed!")}):m.Pledge()})().always(function(){a.resolve(D.enabled)});
return a.promise()},finalize:function(){},reset:function(){return D.enabled?H.reset():m.Breach()},addSyncDoneCallback:function(a){u.push(a)},sync:function(a,b){var c=Date.now();a=a||500;b=e.force||b;e.to?(window.clearTimeout(e.to),e.ts<c+a&&(a=e.ts-c,1>a&&(a=1))):n.debug("sync: schedule sync for run in "+a+" ms");e.force=b;e.ts=c+a;e.to=window.setTimeout(function(){v(e.force);e.to=null;e.force=null},a)},scriptAddedCb:function(a,c){if(D.enabled){var d=g(c);b(d,c.textContent)}},scriptChangedCb:function(){D.enabled&&
D.sync(6E4)},scriptRemovedCb:function(a,b){if(D.enabled){var c=g(b);n.debug("sync: remove",c.name,c.url);H.remove(c)}},getSyncRemoteUrl:function(a){if(D.enabled)return H.getRemoteUrl(a)},getSyncRemoteDomains:function(){return H.getRemoteDomains()||[]}};return D}();sycl=N;var Ja=function(){f.addChangeListener(["sync_enabled","sync_type","cloud_url","cloud_user","cloud_pass"],N.configChangeListener);f.addChangeListener("logLevel",function(){n.set(f.values.logLevel)});f.addChangeListener("i18n",function(){d.setLocale(f.values.i18n)});
f.addChangeListener("native_import_path",function(){Q.setPath(f.values.native_import_path)});f.addChangeListener("incognito_mode",function(){Fa()});f.addChangeListener("statistics_enabled",function(){L.setEnabled(f.values.statistics_enabled)});f.addChangeListener(["require_blacklist","script_blacklist_server","script_blacklist_type"],x.blackCheckAll);f.addChangeListener(["downloads_extension_whitelist","downloads_mode"],K.config_changed_listener);f.addChangeListener("webrequest_modHeaders",function(d,
f,e,h){h.done(window.setTimeout(V.reset,1))})},f=function(){var d={},f={enabled:!0,configMode:0,debug:!1,logLevel:0,showFixedSrc:!1,webrequest_modHeaders:"yes",webrequest_fixCSP:"yes",webrequest_fixContentCSP:"no",notification_showUpdate:"changelog",notification_silentScriptUpdate:!0,script_templates:[{name:"ECMAScript 5",value:"// ==UserScript==\n// @name         New Userscript\n// @namespace    http://tampermonkey.net/\n// @version      0.1\n// @description  try to take over the world!\n// @author       You\n// @match        <$URL$>\n// @grant        none\n// ==/UserScript==\n\n(function() {\n    'use strict';\n\n    // Your code here...\n})();"},
{name:"ECMAScript 6",value:'// ==UserScript==\n// @name         New ES6-Userscript\n// @namespace    http://tampermonkey.net/\n// @version      0.1\n// @description  shows how to use babel compiler\n// @author       You\n// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/6.18.2/babel.js\n// @require      https://cdnjs.cloudflare.com/ajax/libs/babel-polyfill/6.16.0/polyfill.js\n// @match        <$URL$>\n// ==/UserScript==\n\nvar inline_src = (<><![CDATA[\n\n    // Your code here...\n\n]]\x3e</>).toString();\nvar c = Babel.transform(inline_src, { presets: [ "es2015", "es2016" ] });\neval(c.code);'},
{name:"CoffeeScript",value:"// ==UserScript==\n// @name         New Coffee-Userscript\n// @namespace    http://tampermonkey.net/\n// @version      0.1\n// @description  shows how to use coffeescript compiler\n// @author       You\n// @require      http://coffeescript.org/browser-compiler/coffeescript.js\n// @match        <$URL$>\n// ==/UserScript==\n\nvar inline_src = (<><![CDATA[\n\n    // Your code here\n\n]]\x3e</>).toString();\nvar compiled = this.CoffeeScript.compile(inline_src);\neval(compiled);"}],
scriptUpdateCheckPeriod:864E5,scriptUpdateHideNotificationAfter:15E3,scriptUpdateCheckDisabled:!1,scriptUrlDetection:"auto",script_file_access:p.RUNTIME.FIREFOX?"off":"externals",runtime_strict_mode:"byscript",runtime_inject_mode:"default",autoReload:!1,appearance_badges:"running",appearance_badge_color:"gcal"===rea.runtime.short_id?"#444":"#ee3131",editor_enabled:!0,editor_fontSize:100,editor_theme:function(){return"default#dark"==k.values.layout?"default-dark":"default"},editor_keyMap:"windows",
editor_indentUnit:4,editor_indentWithTabs:"spaces",editor_tabMode:"indent",editor_electricChars:!0,editor_autoSave:!1,editor_easySave:!0,editor_autoLint:!0,editor_autoLintMaxLen:3E5,editor_lineWrapping:!1,editor_highlightTrailingWhitespace:!0,editor_trimTrailingSpacesFromModifiedLines:!0,editor_linter_config:null,favicon_service:"google",native_import:!0,native_import_path:null,native_import_post_action:"disable",i18n:null,action_menu_columns:1,action_menu_scripts_hide_disabled:!1,action_menu_scripts_sort:"auto",
incognito_mode:"temporary",layout:"default",layout_user_css:"",sync_enabled:!1,sync_type:2,statistics_enabled:p.RUNTIME.FIREFOX&&"firb"!=rea.runtime.short_id?null:!0,downloads_mode:"default",downloads_extension_whitelist:"/^[^\\.]*$/ /\\.mp[34]$/ .wav /\\.(avi|mkv|flv|divx|mpe?g|webm)$/ /\\.(ico|gif|png|jpe?g)/ /\\.(srt|sub|idx)$/ .txt .iso .zip /\\.r(ar|[0-9]{2,2})$/".split(" "),external_update_interval:6048E5,external_connect:"all",require_timeout:2E4,require_blacklist:["/^https?:\\/\\/example.com(:[0-9]{1,5})?\\/.*/"],
require_sri_mode:"supported",script_blacklist_server:[],script_blacklist_type:"server",script_blacklist_severity:4,connect_mode:"ask",page_filter_mode:"black",page_whitelist:["/https?:\\/\\/greasyfork\\.org\\/.*/","http://xkcd.com/970/"],forbiddenPages:"*example.org/* *paypal.tld/* *stripe.com/* https://*deutsche-bank-24.tld/* https://*bankofamerica.tld/* /^.*:\\/\\/apis\\.google\\.com\\/((?!render)([^\\/]+)\\/)+([^\\/]+)?$/ *://www.facebook.com/plugins/* *://platform.twitter.com/widgets/*".split(" ")},
e={cloud_url:null,cloud_user:null,cloud_pass:null},h=function(a){var b;return void 0!==(b=r.getValue(p.CONSTANTS.STORAGE.CONFIG,{})[a])?b:"function"==typeof(b=f[a])?b():b},l=function(a,b){var c=r.getValue(p.CONSTANTS.STORAGE.CONFIG,{}),g=h(a);c[a]=b;var k=r.setValue(p.CONSTANTS.STORAGE.CONFIG,c);d[a]&&JSON.stringify(g)!=JSON.stringify(b)&&d[a].forEach(function(c){try{c(a,g,b,k)}catch(d){n.warn("config: changeListener error",d)}});return k},c,a;if(p.HTML5.LOCALSTORAGE&&(a=p.HTML5.LOCALSTORAGE.getItem(p.CONSTANTS.STORAGE.SESSION)))try{c=
JSON.parse(J.Base64.decode(a))}catch(v){}c=c||{};var b=function(a){var b;return void 0!==(b=c[a])?b:e[a]},g=function(a,g){var k=b(a);void 0===g?delete c[a]:c[a]=g;p.HTML5.LOCALSTORAGE&&p.HTML5.LOCALSTORAGE.setItem(p.CONSTANTS.STORAGE.SESSION,J.Base64.encode(JSON.stringify(c)));d[a]&&JSON.stringify(k)!=JSON.stringify(g)&&d[a].forEach(function(b){try{b(a,k,g)}catch(c){n.warn("config: changeListener error",c)}});return m.Pledge()},k={init:function(){var a=m();k.values={};k.__defineGetter__("snapshot",
function(){return w.assign({},k.values)});Object.keys(f).forEach(function(a){k.values.__defineGetter__(a,function(){return h(a)});k.values.__defineSetter__(a,function(b){l(a,b)})});Object.keys(e).forEach(function(a){k.values.__defineGetter__(a,function(){return b(a)});k.values.__defineSetter__(a,function(b){g(a,b)})});k.initialized=!0;var c=Ia();Object.keys(c).forEach(function(a){var b=c[a];window.setTimeout(function(){x.doSave({url:null,src:b,ask:!1,replace:!0,internal:!0})},1)});a.resolve();return a.promise()},
getValue:function(a){return e.hasOwnProperty(a)?b(a):h(a)},setValue:function(a,b){return e.hasOwnProperty(a)?g(a,b):l(a,b)},getDefaults:function(){return f},addChangeListener:function(a,b){Array.isArray(a)||(a=[a]);a.forEach(function(a){d[a]||(d[a]=[]);d[a].push(b)})}};return k}(),ba=function(){var f,u,e=[],h,l,c,a=function(){return m.sleep(1).then(function(){return rea.permissions.supported?la.has(p.PERMISSIONS.ALL_URLS).then(function(a){return a},function(){return!0}):!0}).always(function(a){(u=
a)?O.removeAll("runtime_host_permissions"):O.all("status",{key:"runtime_host_permissions",class:"warning",text:d.getMessage("Limited_runtime_host_permissions_might_break_some_Tampermonkey_features_"),timeout:31536E6});h=null})},b=function(b,d,v){var t={details:b,callbacks:d,internal:v};e.push(t);m.Pledge().then(function(){if(void 0===u)return c||(la.addListener(function(b){n.log("pcx: detected permission change",b);u=void 0;h=a()}),c=!0),h||(h=a()),h}).then(function(){return l}).then(function(){var a=
e;e=[];if(u)return a;var b=[],c=a.map(function(a){var c=A.woPath(a.details.url)+"/*";return la.hasOrigin(c).then(function(a){a||b.push(c)})});return l=m.sidebyside(c).then(function(){b.length&&(n.log("pcx: need to ask for some permissions",b),n.warn("pcx: asking for host permissions is not working yet","https://bugs.chromium.org/p/chromium/issues/detail?id=889654"));return a}).always(function(){l=null})}).always(function(a){a.forEach(function(a){a.aborted||(a.xhr=f(a.details,a.callbacks,a.internal?
{internal:!0}:void 0))})});return{abort:function(){var a;if(t.xhr)return t.xhr.abort();e&&-1!=(a=e.indexOf(t))?e.splice(a,1):t.aborted=!0}}};return{init:function(){f=W.run},internal:function(a,c){return b(a,c,!0)},external:function(a,c){return b(a,c)}}}(),sa=function(){var d=m();rea.tabs.getSelected(null,function(f){d.resolve(f)});return d.promise()},ja=function(){var d={},u=function(a){if(A.isIpOrHostname(a))return null;var b=a.split(".");if(3>b.length)return a;a=A.isSecondLevelDomain(b.slice(-2).join("."))?
-3:-2;return b.slice(a).join(".")},e=function(a){return a&&-1!=a.indexOf("*")},h=function(a){var b=m();T.isAllowed(a)?b.resolve({allowed:!0}):b.resolve({allowed:!1});return b.promise()},l=function(a,b){var c=function(a){return a?a.map(function(a){if(a.match(/^'?self'?$/))a=A.parse(b.url).hostname||null;else if("'none'"==a)a="none";else if(-1===["none","localhost","*"].indexOf(a)&&!A.isIpOrHostname(a)&&(0===a.indexOf(".")||1===(a.match(/\./g)||[]).length&&A.isSecondLevelDomain(a)))return null;return a}):
[]};return{connects:a.options.override.merge_connects&&"paranoid"!=f.values.connect_mode?c(a.connects):[],userconnects:c(a.options.override.use_connects),blockers:c(a.options.override.use_blockers)}},c=function(a,b,c){var g=m(),k=function(){g.resolve({permitted:!0})},v=function(a){g.resolve({permitted:!1,reason:a})},h=function(){g.resolve({unknown:!0})},l,u=function(a,b){var c=null,g=A.isIpOrHostname(a);b.every(function(b){if(b.a)for(var d=0;d<b.a.length;d++)if(b.a[d]&&(g||A.isIpOrHostname(b.a[d])?
b.a[d]===a:-1!=a.search(new RegExp("(^|.+\\.)"+w.escapeForRegExp(b.a[d])+"$"))))return c=b.blocker?v:k,!1;return!0});return c};if("off"==f.values.connect_mode)k();else if((l=A.parse(c))&&l.hostname)if((c=u(l.hostname,[{a:d[a.uuid]}]))||(c=e(d[a.uuid])?k:null))c();else if(0===b.connects.length&&0===b.userconnects.length&&0===b.blockers.length)"casual"==f.values.connect_mode?k():"strict"==f.values.connect_mode?v("No @connects given, but strict mode enabled"):h();else if(-1!=b.connects.indexOf("none"))v("None value found");
else{if("casual"!=f.values.connect_mode||e(b.blockers)||!(c=e(b.connects)?k:null))(c=e(b.userconnects)?k:null)||(c=u(l.hostname,[{a:b.blockers,blocker:!0},{a:b.connects},{a:b.userconnects}])||h);c()}else v("URL can not be parsed");return g.promise()},a=function(){var a=function(a){for(var b=0;b<g.length;b++)if(g[b].tabId===a)return g.splice(b,1)[0];return g.pop()},c;sa().then(function(g){for(;!b&&(c=a(g.id));)c.fn()})},b,g=[],k=function(c,k,v,h,f){var l,p=m(),Y=function(){p.resolve({approved:!0})},
oa=function(){p.resolve({forbidden:!0})};n.debug('cor: "'+c.name+'" is asking for permission to access',h,k);if((l=A.parse(h))&&l.hostname){var Da=u(l.hostname),r=k.tab?k.tab.id:null;b=!0;sa().then(function(a){return X.askForConnect({src_url:k.url,hostname:l.hostname,domain:Da,all_domains:e(v.connects),tabid:r,active:r===a.id,timeout:f,url:h,settings_url:rea.extension.getURL("options.html")+"#nav="+c.uuid+"+settings",connect_url:"https://www.tampermonkey.net/documentation.php#_connect",script:{name:c.name,
uuid:c.uuid,icon:c.icon64||c.icon||rea.extension.getURL("images/txt.png")}})}).done(function(a){var b,g=a.whole_domain?Da:l.hostname;a.allow?a.once?(n.debug('cor: allowing "'+c.name+'" to access',g,"once"),Y()):a.temporary?(n.debug('cor: allowing "'+c.name+'" to access',g,"temporarily"),void 0===d[c.uuid]&&(d[c.uuid]=[]),-1==d[c.uuid].indexOf(g)&&d[c.uuid].push(g),Y()):(b=Y,a.all_domains?(n.debug('cor: allowing "'+c.name+'" to access all domains always'),c.options.override.use_connects.push("*")):
(n.debug('cor: allowing "'+c.name+'" to access',g,"always"),c.options.override.use_connects.push(g),b=Y)):a.once||a.aborted?(n.debug('cor: denying "'+c.name+'" to access',g,"once"),oa()):(c.options.override.use_blockers||(c.options.override.use_blockers=[]),b=oa,a.all_domains?(n.debug('cor: denying "'+c.name+'" to access any domains (additional) domain'),c.options.override.use_blockers.push("*")):(n.debug('cor: denying "'+c.name+'" to access',g,"always"),c.options.override.use_blockers.push(g)));
b&&x.doModify(c.uuid,c,!1).always(b)}).fail(oa).always(function(){b=!1;g.length&&window.setTimeout(a,1)})}else oa();return p.promise()},v=function(a,d,q,F){var B=l(a,d),u=arguments;return h(q).then(function(b){if(!0!==b.allowed)return m.Breach("URL is blacklisted");var g,k;return(g=A.parse(q))&&g.origin&&(k=A.parse(d.url))&&k.origin&&g.origin===k.origin?m.Pledge({permitted:!0}):c(a,B,q)}).then(function(c){if(!1===c.permitted)return m.Breach("URL is not permitted"+(c.reason?": "+c.reason:""));if(!0===
c.permitted)return m.Pledge();if(0===B.connects.length||e(B.connects)){if(-1==["ask","paranoid"].indexOf(f.values.connect_mode))return m.Breach();if(e(B.blockers))return m.Breach("URL was permanently blocked by the user");if(b){n.debug('cor: queuing access permission check from "'+a.name+'" to',q,d);var h=m();g.push({tabId:d.tab?d.tab.id:null,fn:function(){h.consume(v.apply(this,u))}});return h.promise()}return k(a,d,B,q,F).then(function(a){return!0===a.approved?m.Pledge():m.Breach("Request was blocked by the user")})}return m.Breach("URL is not a part of the @connect list")})};
return{getSessionConnects:function(a){return d[a]||[]},setSessionConnects:function(a,b){d[a]=b||[]},purgeAppeals:function(a){g=g.filter(function(b){return b.tabId!==a})},exec:function(a,b,c,g){var d,k,e,h,f=a.url,q=[],l=Math.max(Math.min(a.timeout||0,6E4),2E4),u=function(){for(var a;!e&&!h&&(a=q.shift());)a()},m=function(b,c){var d='Refused to connect to "'+(c||a.url)+'": '+(b||"Blocked by @connect CORS check"),k=W.makeErrorResponse(d);["onerror","ondone"].forEach(function(a){if(g[a])g[a]({response:k,
exception:d})})};if(!(c&&c.url&&c.tab&&a.url&&b&&(k=z.getByUid(b))&&k.script&&k.cond))return m();v(k.script,c,a.url,l).done(function(){var b={};Object.keys(g).forEach(function(a){b[a]=function(t){var y=arguments;e||(h?q.push(function(){b[a].apply(this,y)}):function(){return t&&t.finalUrl&&f!==t.finalUrl?(h=!0,v(k.script,c,t.finalUrl,l).fail(function(){e||(d&&d.abort(),e=!0,m("Request was redirected to a not whitelisted URL",t.finalUrl),n.warn("cor: request to",f,"was redirect to a not whitelisted URL",
t.finalUrl))}).always(function(){f=t.finalUrl;h=!1;q.length&&window.setTimeout(u,1)})):{always:function(a){a()}}}().always(function(){if(!e)g[a]({response:t})}))}});d=ba.external(a,b)}).fail(function(a){m(a);n.warn("cor: access to",f,"was denied")});return{abort:function(){e=!0;d&&d.abort()}}}}}(),va=function(){var d=function(a){var b=[];a=new DataView(a);for(var c=0;c<a.byteLength;c+=4){var d=("00000000"+a.getUint32(c).toString(16)).slice(-8);b.push(d)}return b.join("")},f={md5:function(a,b){return m.Pledge(J.MD5(a,
b))}},e={};["SHA-1","SHA-256","SHA-384","SHA-512"].forEach(function(a){var b=a.toLowerCase().replace("-","");e[b]=function(){var b=function(b,c){var g=m();window.crypto.subtle.digest(a,J.str2arrbuf(b,c)).then(function(a){g.resolve(d(a))},function(){g.reject()});return g.promise()};try{return b("").then(function(a){if(a&&a.substr(0,4).toLowerCase().match(/[0-9a-f]{4,4}/))return b})}catch(c){return m.Breach()}}});var h=function(a){return-1!=Object.keys(f).indexOf(a)},l=function(a){return function(){if(!1!==
c){var b=arguments,g=m();c.push(function(){g.consume(a.apply(this,b))});return g.promise()}return a.apply(this,arguments)}},c=[];return{init:function(){n.D&&Object.keys(f).forEach(function(a){n.debug("sri:",a,"is supported")});return m.sidebyside(Object.keys(e).map(function(a){return e[a]().done(function(b){n.debug("sri:",a,"is supported");f[a]=b}).fail(function(){n.debug("sri:",a,"is unsupported")})})).always(function(){c.forEach(function(a){a()});c=!1})},isSupported:l(function(a){return m.Pledge(h(a))}),
getHash:l(function(a,b){var c=m();"string"===typeof a&&(a=A.parse(a));if(a&&a.hash){for(var k,e,t=a.hash.replace(/^#/,"").split(/,|;/g),f=0;f<t.length;f++)if((e=t[f].match(/([^=|:|-]+)[=|:|-](.+)/))&&3==e.length&&h(e[1])){k=e[2];if(!/^[0-9a-fA-F]+$/.exec(k)){var l;var F=decodeURIComponent(k);try{l=d(J.str2arrbuf(J.Base64.decode(F)))}catch(B){l=null}k=l||k}k={type:e[1],value:k}}c.resolve(k||(b?k:{type:"unsupported",value:""}))}else c.resolve();return c.promise()}),check:l(function(a,b,c){return b&&
a&&h(a.type)?f[a.type](b,c).then(function(b,c){return((c=b===a.value)?m.Pledge:m.Breach)(c||{type:a.type,value:b})}):m.Breach()})}}(),P=function(){var d={key:function(a,b){return p.CONSTANTS.PREFIX.EXTERNAL+w.select([a,b?J.MD5(b):null],function(a){return a}).join(":")},list:function(a){var b=new RegExp("^"+a);return w.select(r.listValues(),function(a){return-1!=a.search(b)})},set:function(a,b,c,k){a=d.key(a,b);var e={};w.each(c,function(a,b){"content"==b&&(b="base",a=J.encodeS(a));e[b]=a});r.setValue(a,
{ts:Date.now(),url:b,resource:e,modified:k})},get:function(a,b){var c=d.key(a,b),c=r.getValue(c),k;if(c&&c.resource){var e={};w.each(c.resource,function(a,b){"base"==b&&(b="content",a=J.decodeS(a));e[b]=a});k={ts:c.ts,url:c.url,data:e,modified:c.modified}}return k},clean:function(a,b){var c=d.key(a,b);r.deleteValue(c)},cleanAll:function(a,b){var c,k=d.list(d.key(a));if(b){var e={};w.each(b,function(b){b=d.key(a,b);e[b]=!0});c=[];w.each(k,function(a){e[a]||c.push(a)})}else c=k;c.forEach(function(a){r.deleteValue(a)})}},
u=function(a,b){var c=m(),d=function(d){var k={content:""};if(4!=d.readyState||200!=d.status&&0!=d.status||d.error)c.reject(k);else{var e,h,v=W.parseHeaders(d.responseHeaders)["content-type"];v&&v.match("(image/|text/)([.-a-zA-Z0-9]+)")&&(e=v);e||(a.match(".*.(ico|jpg|jpeg)+($|\\?|#).*")?e="image/x-icon":(h=a.match(".*.(gif|png)+($|\\?|#).*"))?e="image/"+h[1]:-1!=a.search(".*.(js)+($|\\?|#).*")?e="text/javascript":(h=a.match(".*.(css|html|xml)+($|\\?|#).*"))?e="text/"+h[1]:w.isLocalImage(a)&&(e="image/x-icon"));
k.meta=e;k.content=J.arrbuf2str(d.response,b.encoding)||"";c.resolve(k)}},e=function(){c.reject({})},h=A.parse(a);-1!=["file:",p.REQUESTS.INTERNAL_PAGE_PROTOCOL].indexOf(h.protocol)?"file:"!=h.protocol||p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS&&-1!=["externals","all"].indexOf(f.values.script_file_access)?rea.file.get(a,function(a){d({readyState:4,status:0,response:a})},function(a){e({error:!0,responseText:a})}):(n.warn("externals:","Access to this local file is forbidden!","Loading the following @resource failed:",
a,"-> more info:","https://www.tampermonkey.net/faq.php#Q204"),e({error:!0,responseText:"Access to this local file is forbidden!"})):(h={method:"GET",url:a,retries:p.XMLHTTPREQUEST.RETRIES,nocache:!1,responseType:"arraybuffer"},h.timeout=f.values.require_timeout,ba.internal(h,{onload:d,onerror:e,ontimeout:e}));return c.promise()},e=w.getDebouncer(9E3),h=function(a,b,c,k){var e=m(),h={sync:!1};u(b,{encoding:k.encoding}).done(function(y){c&&(y.sri=c);var l=function(c){var g=A.parse(b);g.protocol&&-1==
["file:",p.REQUESTS.INTERNAL_PAGE_PROTOCOL].indexOf(g.protocol)&&d.set(a,b,c)};c&&-1!=["supported","given"].indexOf(f.values.require_sri_mode)?va.check(c,y.content,k.encoding).done(function(){h.resource=y;l(h.resource);e.resolve(h)}).fail(function(a){h.resource={forbidden:!0,sri:{mode:f.values.require_sri_mode,type:c.type,value:"invalid"},determined:a,content:""};l(h.resource);e.reject(h)}):(h.resource=y,l(h.resource),e.resolve(h))}).fail(function(c){n.debug("externals: get.failed",a,b,c);h.resource=
{failed:!0,content:""};e.reject(h)});return e.promise()},l=function(a,b,c){var k=m(),v=A.parse(b),t={sync:c.sync},y;b?G.getEvilnessOf(b)>=f.values.script_blacklist_severity?(t.resource={blacklisted:!0,content:""},k.reject(t)):va.getHash(v,"supported"==f.values.require_sri_mode).done(function(l){if("enforce"!=f.values.require_sri_mode||l)if("file:"!==v.protocol&&(y=d.get(a,b))){var F=d.key(a,b),B=Date.now();0<f.values.external_update_interval&&B-y.ts>f.values.external_update_interval&&!e.is(F)&&(1<
f.values.external_update_interval&&e.add(F),y.modified?n.debug("externals: resource is not updated due to user modifications",b,(new Date(y.ts)).toISOString(),(new Date(B)).toISOString()):(n.debug("externals: resource needs update",b,(new Date(y.ts)).toISOString(),(new Date(B)).toISOString()),window.setTimeout(function(){h(a,b,l,c)},3E3)));t.resource=y.data;t.resource.forbidden||t.resource.blacklisted?k.reject(t):k.resolve(t)}else k.consume(h(a,b,l,c));else t.resource={forbidden:!0,sri:{mode:f.values.require_sri_mode},
content:""},k.reject(t)}):(t.resource={forbidden:!0,content:""},k.reject(t));return k.promise()},c={setElement:function(a,b,c,k){return d.set(a,b,c,k)},getElement:function(a,b){return d.get(a,b)},cleanElement:function(a,b){return d.clean(a,b)},dropAll:function(a){d.cleanAll(a);return m.Pledge()},dropAllBut:function(a,b){d.cleanAll(a,b);return m.Pledge()},loadResources:function(a,b){var g=m();c.getResources(a,b).always(function(){g.resolve()});return g.promise()},loadRequires:function(a,b){var g=m();
c.getRequires(a,b).always(function(){g.resolve()});return g.promise()},getResources:function(a,b){var c={elements:[]},d=m(),e=[],h={sync:!0};b.forEach(function(b){var d=b.url||A.sanitize(b.unsafe_url,b.abs_url),k={name:b.name,url:d},d=l(a,d,h),f=m();d.done(function(a){a=a.resource;k.content=a.content;k.meta=a.meta||"application"}).fail(function(a){a.resource&&a.resource.forbidden?a.resource.sri?n.warn("externals: can't load @resource",b.name,"from URL",b.unsafe_url,"due to a SRI error"):n.warn("externals: can't load @resource",
b.name,"from forbidden URL",b.unsafe_url):a.resource&&a.resource.blacklisted?n.warn("externals: can't load @resource",b.name,"from blacklisted URL",b.unsafe_url):(n.warn("externals: can't load @resource",b.name,"from URL",b.unsafe_url),k.failed=!0);k.content=null}).always(function(a){h.sync&=a.sync;c.elements.push(k);f.resolve()});e.push(f)});m.when(e).always(function(){c.sync=h.sync;d.resolve(c)});return d.promise()},getRequires:function(a,b){var c={elements:[]},d=m(),e=[],h={encoding:"UTF-8",sync:!0};
w.each(b,function(b,d){var k=b.url||A.sanitize(b.unsafe_url,b.abs_url),f={},k=l(a,k,h),q=m();k.done(function(a){f.textContent=a.resource.content||""}).fail(function(a){a=a.resource&&a.resource.forbidden?a.resource.sri?"couldn't load @require from URL "+b.unsafe_url+" due to a SRI error":"couldn't load @require from forbidden URL "+b.unsafe_url:a.resource&&a.resource.blacklisted?"couldn't load @require from blacklisted URL "+b.unsafe_url:"couldn't load @require from URL "+b.unsafe_url;f.textContent=
'console.warn("Tampermonkey: " + decodeURIComponent("'+encodeURIComponent(a)+'"));\n';n.warn("externals: "+a)}).always(function(a){h.sync&=a.sync;c.elements[d]=f;q.resolve()});e.push(q)});m.when(e).always(function(){c.sync=h.sync;c.elements=c.elements.filter(function(a){return a});d.resolve(c)});return d.promise()}};return c}();exts=P;var Ea=function(){var d=function(d,h,l){var c=m(),a=[];l.forEach(function(b){b=b.textContent||"";b=ta.mkCompat(b,d.options.compatopts_for_requires?d:null,"off"!=f.values.runtime_strict_mode);
a.push(b)});l="\n"+a.join("\n")+"\n";var b=z.getStorageByUid(d.uuid);h=ta.mkCompat(h,d,"off"!=f.values.runtime_strict_mode);if(f.values.debug){h=h.split("\n");for(var g=!1,k,v=0;v<h.length;v++)if(k=h[v],!k.match(/^\s*$|^\s*\/\/\s*|^\s*\/\*.*\*\/\s*$|^\s*["']+use strict["']+;*\s*$/))if(k.match(/^\s*\/\*/)&&(g=!0),g)if(k.match(/\*\/\s*$/))g=!1;else{if(-1!=(k=k.search(/\*\//))){h[v]=w.insert(h[v],k+2,0,"debugger;");break}}else{h[v]="debugger;"+h[v];break}h=h.join("\n")}l={header:d.header,code:h,requires:l,
storage:b,script:d,source_url:rea.extension.getURL("userscript.html")+"?id="+d.uuid};c.resolve(l);return c.promise()},u={};return{bundle:function(e,h){var f,c,a=!0;if(f=u[h.uuid])return f;var b={},g="includes matches requires resources excludes connects textContent".split(" ");Object.keys(h).forEach(function(a){-1==g.indexOf(a)&&("options"==a?(b[a]=JSON.parse(JSON.stringify(h[a])),b[a].run_at=b[a].run_at||h.options.override.orig_run_at||"document-idle"):b[a]=h[a])});f=P.getResources(b.uuid,h.resources).then(function(c){a&&
!c.sync&&(n.debug("ri: uncached @external detected -> fast script start disabled"),a=c.sync);b.resources=c.elements;return P.getRequires(b.uuid,h.requires)}).then(function(c){a&&!c.sync&&(n.debug("ri: uncached @external detected -> fast script start disabled"),a=c.sync);c=c.elements;n.debug("run script "+b.name+" @ "+e.url);return d(b,h.textContent,c)}).always(function(){c=!0;delete u[b.uuid]});c||(u[b.uuid]=f);return f}}}(),O=function(){var d={},f={},e=function(c,a){var b,g=a.key||"general",d=a.timeout||
3E5,e=window.setTimeout(function(){delete c[g]},d);(b=c[g])&&window.clearTimeout(b.to);c[g]={ts:Date.now()+d,options:a,to:e}},h=function(c){var a=Date.now();return Object.keys(c).map(function(b){var g=c[b];b=w.copy(g.options,{});if(g=Math.max(0,g.ts-a))return b.timeout=g,b}).filter(function(a){return a})},l={all:function(c,a){l.actionPage(c,a);l.optionsPage(c,a)},removeAll:function(c){delete d[c];delete f[c]},actionPage:function(c,a){var b=rea.extension.getViews({type:"popup"});b&&b.length&&rea.extension.sendMessage({method:c,
options:a},function(){});a&&e(d,a)},optionsPage:function(c,a){var b=rea.extension.getViews({type:"tab"});b&&b.length&&rea.extension.sendMessage({method:c,options:a},function(){});a&&e(f,a)},actionStatus:function(){return h(f)},optionsStatus:function(){return h(d)}};return l}(),aa=function(){return{getConfig:function(){var d={version:0,last:0},f={scripts:0},e=r.getValue(p.CONSTANTS.STORAGE.UPDATE,f);"object"!==typeof e&&(e=f);e||(e=f);void 0==e.black&&(e.black=d);void 0==e.scripts&&(e.scripts=0);return e},
setConfig:function(d){d&&r.setValue(p.CONSTANTS.STORAGE.UPDATE,d)}}}(),ca=function(){var q=function(h,l){var c=0,a=0,b=0,g=d.getMessage("Script_Update"),k=d.getMessage("Check_for_userscripts_updates")+"...";h&&S.show(g,k,rea.extension.getURL("images/icon128.png"),1E4);var v=z.getUidList().map(function(g){var k,h,v,B,q,u;return function(){B=z.getByUid(g);if(!B.script||!B.cond)return n.warn("update: inconsistent script entry",g,B),m.Breach();var a=!f.values.scriptUpdateCheckDisabled&&!B.script.enabled&&
!l||!B.script.options.check_for_updates;if(l&&B.script.uuid!==l||a||!(u=x.determineSourceURL(B.script))||B.script.evilness&&B.script.evilness>=Math.min(G.SEVERITY_MAX,f.values.script_blacklist_severity))return m.Breach();var b;if((b=x.determineOrigin(B.script))&&b.updates_allowed&&!b.updates_allowed(u))return m.Breach();c++;n.info("update: check for script updates @",g);return m.Pledge()}().then(function(){var a=x.determineMetaURL(B.script);if(!a)return m.Pledge();if("none"==a)return n.log("update: ignore non-updatable script",
B.script.name),m.Breach();var b=m();ba.internal({method:"GET",retries:p.XMLHTTPREQUEST.RETRIES,timeout:1E3*p.SCRIPT_DOWNLOAD.TIMEOUT,revalidate:!0,headers:{Accept:"text/x-userscript-meta, */*"},url:a},{ondone:function(c){4==c.readyState&&200==c.status?q=C.processMetaHeader(c.responseText):n.warn("update: unable to find meta data @ "+a+" req.status = "+c.status);b.resolve()}});return b.promise()}).then(function(){var a=!!q,b=a&&!!q.version,c=b&&(!B.script.version||C.versionCmp(q.version,B.script.version)==
C.versionCmp.eNEWER);return a&&b&&!c?m.Breach():m.Pledge()}).then(function(){var a;if(a=A.parse(u)){if(a.protocol.match(/(https?|file):/))return e.getScriptFromURL(u).fail(function(){n.warn("update: failed",B.script.name,u)});n.warn("update: can't download URL",B.script.name,u)}else n.warn("update: can't parse URL",B.script.name,u)}).then(function(b){var c;c=B.script.uuid;var g=C.createScriptFromSrc(b);if(!g.name||""==g.name||void 0===g.version||g.options.compat_uW_gmonkey)c=C.versionCmp.eERROR;else{var d;
c=(d=z.getMetaByUid(c))?d.system?null:g.version==d.version?C.versionCmp.eEQUAL:C.versionCmp(g.version,d.version):C.versionCmp.eNEWER}return c==C.versionCmp.eNEWER?(a++,k=B.script.name,h=u,v=b,m.Pledge()):m.Breach()}).then(function(){if(f.values.notification_silentScriptUpdate)return m.Pledge();var a=d.getMessage("There_is_an_update_for_0name0_avaiable_",k)+"\n"+d.getMessage("Click_here_to_install_it_"),b=d.getMessage("Just_another_service_provided_by_your_friendly_script_updater_")+":",c=m();S.show(b,
a,rea.extension.getURL("images/icon128.png"),f.values.scriptUpdateHideNotificationAfter,c.resolve);return c.promise()}).then(function(a){var c=g||B.script.uuid;return void 0===a||a.clicked?x.doSave({url:h,uuid:c,replace:!c,src:v,ask:!f.values.notification_silentScriptUpdate}).done(function(a){a&&a.installed&&b++}):m.Breach()})});c&&O.all("status",{key:"script_update",class:"information",title:g,text:k,timeout:1E4});return m.sidebyside(v).then(function(){v.length&&0==a&&(n.debug("No update found"),
h&&S.show("Narf!",d.getMessage("No_update_found__sry_"),rea.extension.getURL("images/icon128.png"),1E4),O.all("status",{key:"script_update",class:"information",text:d.getMessage("No_update_found__sry_"),timeout:1E4}));return{found:a,installed:b}})},u=null,e={check:function(e,l,c){if(!e&&0>=f.values.scriptUpdateCheckPeriod)return m.Breach();var a=aa.getConfig();if(!e&&Date.now()-a.scripts<Math.max(f.values.scriptUpdateCheckPeriod,36E5))return m.Breach();var b,g;return m.Pledge().then(function(){var a=
function(){g=null;var a=d.getMessage("Script_Update"),b=d.getMessage("Waiting_for_sync_to_finish")+"...";g=S.show(a,b,rea.extension.getURL("images/icon128.png"),6E4)};if(N.enabled){var c=m();N.addSyncDoneCallback(c.resolve);N.sync(50,!1);l&&(b=window.setTimeout(a,500));return c.promise()}}).then(function(){if(!e){var a=m(),b=function(){rea.idle.queryState(p.MISC.IDLE_TIMEOUT,function(a){"active"==a?window.setTimeout(b,1E3*Math.round(p.MISC.IDLE_TIMEOUT/2)):c()})},c=function(){var c;rea.windows.getAll({},
function(g){g.forEach(function(a){"fullscreen"===a.state&&(c=!0)});c?window.setTimeout(b,1E3*p.MISC.IDLE_TIMEOUT):a.resolve()})};b();return a.promise()}}).then(function(){var d=m();b&&(window.clearTimeout(b),b=null);g&&g.cancel();q(l,c).done(function(a){d.resolve(a.installed)}).fail(function(){d.resolve(null)});a=aa.getConfig();a.scripts=Date.now();aa.setConfig(a);return d.promise()})},getScriptFromURL:function(d){var e=m();-1!=["file:",p.REQUESTS.INTERNAL_PAGE_PROTOCOL].indexOf(A.parse(d).protocol)?
rea.file.get(d,function(c){e.resolve(J.arrbuf2str(c))},function(c){e.reject({error:!0,responseText:c})}):ba.internal({method:"GET",retries:p.XMLHTTPREQUEST.RETRIES,timeout:1E3*p.SCRIPT_DOWNLOAD.TIMEOUT,revalidate:!0,headers:{Accept:"text/x-userscript, */*"},url:d},{onload:function(c){4!=c.readyState||200!=c.status&&0!=c.status||c.error?e.reject({error:!0,responseText:c.responseText}):e.resolve(c.responseText)},onerror:function(c){e.reject({error:!0,responseText:c.responseText})},ontimeout:function(){e.reject({timeout:!0,
responseText:""})}});return e.promise()},init:function(){var d=function(){u&&(window.clearTimeout(u),u=null);0<f.values.scriptUpdateCheckPeriod&&(u=window.setTimeout(function(){u=null;e.check();d()},36E5))};d();f.addChangeListener("scriptUpdateCheckPeriod",d)}};return e}();trup=ca;var x=function(){var q=function(c){c.sort(function(a,b){return a.position-b.position});return c},u=function(c){void 0===c.ask&&(c.ask=!0);if(void 0===c.url||null==c.url)c.url="";""===c.force_url&&(c.force_url=null);var a=
C.createScriptFromSrc(c.src),b=null,g={heading:null,errors:[],info:[],warnings:[],flags:{}},k=m(),e=Date.now(),h=c.save&&!c.ask&&f.values.editor_easySave,y=c.uuid,q,F;a.name&&void 0!=a.version?F=m.Pledge():(g.errors.push(d.getMessage("Invalid_UserScript__Sry_")+"\n\n"),c.name&&g.errors.push(d.getMessage("Script_name_0name0",c.name)+"\n\n"),c.url&&g.errors.push(d.getMessage("Downloaded_from_0url0",c.url)),n.warn("scriptman: invalid userscript",g,a),F=m.Breach());F.then(function(){c.replace&&!y&&(y=
z.getUidsByName(a.name,a.namespace)[0]);if(y)b=z.getMetaByUid(y);else if(a.uuid)y=a.uuid;else if(c.replace)y=w.createUUID();else return n.warn("scriptman: neither UUID, @uuid nor replace option set"),m.Breach();if(""!==y.replace(/[a-f0-9]{8}-[a-f0-9]{4}-4[a-f0-9]{3}-[89aAbB][a-f0-9]{3}-[a-f0-9]{12}/,""))return n.warn("scriptman: invalid UUID",y),m.Breach();if(!c.clean&&!c.defaultscript&&b&&b.system)return m.Breach()}).then(function(){if(c.clean&&c.name&&c.name!=a.name||-1!=a.name.search("\n"))return g.errors.push(d.getMessage("Invalid_UserScript_name__Sry_")),
m.Breach()}).then(function(){if(a.options.compat_uW_gmonkey)return g.errors.push(d.getMessage("This_script_uses_uW_gm_api_")),m.Breach()}).then(function(){if(b){b.name!=a.name&&(g.flags.renamed=!0);c.internal||b.evilness!=G.SEVERITY_FOISTED_SCRIPT||(g.warnings.push(d.getMessage("This_is_a_possibly_foisted_script_and_a_modification_will_enable_it_")),g.flags.forceAsk=!0);if(b.lastModified&&void 0!==c.lastModTime&&b.lastModified!==c.lastModTime){var k=d.getMessage("some_secs");try{var f=Math.max(1,
Math.floor((e-b.lastModified)/1E3));isNaN(f)||(k=f)}catch(y){}g.warnings.push(d.getMessage("CONFLICT__This_script_was_modified_0t0_seconds_ago_",k));g.flags.forceAsk=!0}a.version==b.version&&(c.save?g.flags.modification=!0:g.flags.reset=!0);c.clean&&(g.flags.factory=!0);q=!c.internal}else g.flags.first_install=!0,q=!c.internal||c.save;a.includes.length||a.matches.length||h||c.internal||g.warnings.push(d.getMessage("This_script_does_not_provide_any__include_information_"));g.flags.sync=!!c.sync;g.flags.internal=
c.internal;g.flags.ask=c.ask;g.flags.save=c.save}).then(function(){a.uuid=y;a.system=c.defaultscript;a.evilness=x.getEvilness(a);a.position=x.determineLastPosition()+1;a.lastModified=e;if(c.force_meta){var d;if(d=c.force_meta.fileURL)a.fileURL=d;if(d=c.force_meta.lastModified)a.lastModified=d}g.flags.factory||g.flags.reset?b&&(a.lastModified=b.lastModified):(c.force_url&&(a.updateURL=null,a.downloadURL=c.force_url),b&&(a.options.override=b.options.override,a.options.comment=b.options.comment,a.options.check_for_updates=
b.options.check_for_updates));["includes","excludes","matches","connects"].forEach(function(b){a.options.override["orig_"+b]=a[b]});a.options.override.orig_noframes=a.options.noframes;a.options.override.orig_run_at=a.options.run_at||"document-idle";a.options.noframes=null;a.options.run_at=null}).then(function(){if(b&&(a.fileURL=b.fileURL,a.position=b.position,b.sync&&(a.sync=b.sync),!g.flags.factory&&!g.flags.reset)){a.enabled=b.enabled;a.options.noframes=b.options.noframes;a.options.run_at=b.options.run_at;
a.options.awareOfChrome||(a.options.compat_forvarin=b.options.compat_forvarin);c.save&&!c.force_url&&(a.downloadURL=b.downloadURL||a.downloadURL);var k=l.determineMetaURL(b),e=l.determineMetaURL(a),k=k?A.woHash(k):k,e=e?A.woHash(e):e;k==e||h||c.internal||g.warnings.push(d.getMessage("The_update_url_has_changed_from_0oldurl0_to__0newurl0",[k,e]));c.save||(w.adiff(b.includes,a.includes,"notinfirst").length+w.adiff(b.matches,a.matches,"notinfirst").length+w.adiff(a.excludes,b.excludes,"notinfirst").length&&
g.warnings.push(d.getMessage("At_least_one_of_the_include_match_or_exclude_statements_was_changed_")),w.adiff(b.connects||[],a.connects||[],"notinfirst").length&&g.warnings.push(d.getMessage("At_least_one_new_connect_statement_was_added_")))}}).then(function(){if(b&&!g.flags.factory&&a.version==b.version&&(c.defaultscript||c.noreinstall))return m.Breach()}).then(function(){b?(g.flags.factory||g.flags.reset?(g.flags.reset?(g.heading=d.getMessage("You_are_about_to_reinstall_a_UserScript_"),g.flags.reinstall=
!0):(g.heading=d.getMessage("You_are_about_to_install_a_UserScript_"),g.flags.install=!0),c.internal||g.warnings.splice(0,0,d.getMessage("All_script_settings_will_be_reset_"))):g.flags.modification?g.heading=d.getMessage("You_are_about_to_modify_a_UserScript_"):C.versionCmp(a.version,b.version)==C.versionCmp.eOLDER?(g.heading=d.getMessage("You_are_about_to_downgrade_a_UserScript"),g.flags.downgrade=!0,h||c.internal||g.warnings.splice(0,0,d.getMessage("The_downgraded_script_might_have_problems_to_read_its_stored_data_"))):
(g.heading=d.getMessage("You_are_about_to_update_a_UserScript_"),g.flags.update=!0),g.info.push({label:d.getMessage("Installed_Version_"),value:"v"+b.version})):(g.heading=d.getMessage("You_are_about_to_install_a_UserScript_"),h||c.internal||(g.info.splice(0,0,d.getMessage("Malicious_scripts_can_violate_your_privacy_")),G.getWarningsFor(l.determineSourceURL(a)).forEach(function(a){g.warnings.splice(0,0,a)})),g.flags.install=!0);g.flags.install?g.action=d.getMessage("Install"):g.flags.reinstall?g.action=
d.getMessage("Reinstall"):g.flags.modification?g.action=d.getMessage("Modify"):g.flags.downgrade?g.action=d.getMessage("Downgrade"):g.flags.update&&(g.action=d.getMessage("Update"))}).then(function(){c.url&&(a.fileURL=c.url);c.sync&&(a.sync=c.sync);c.force_options&&w.copy(c.force_options,a.options,(new C.Script).options,!0);c.force_settings&&w.copy(c.force_settings,a,["enabled","position"]);a=x.mergeCludes(a)}).then(function(){var b=!1,k;for(k in a.options)if(-1!=k.search("compat_")&&!0===a.options[k]){b=
!0;break}b&&g.info.push({label:d.getMessage("Note"),value:d.getMessage("A_recheck_of_the_GreaseMonkey_FF_compatibility_options_may_be_required_in_order_to_run_this_script_")});var e,h;(e=l.determineOrigin(a))&&(h=e.convert)&&(b=h(a),b.warning&&(c.internal?g.info.push(b.warning):g.warnings.push(b.warning)),a=b.script)}).then(function(){["requires","resources"].forEach(function(b){a[b]=w.map(a[b],function(b){b.unsafe_url=b.url;b.abs_url=a.fileURL?a.fileURL.split("/").slice(0,-1).join("/"):null;b.url=
null;return b})})}).done(function(){k.resolve({script:a,oldscript:b,messages:g,trigger_sync:!!q,short_info:[{label:d.getMessage("Author"),prop:"author"},{label:d.getMessage("Description"),prop:"description"},{label:d.getMessage("Source"),prop:"fileURL"}]})}).fail(function(){k.reject({messages:g})});return k.promise()},e=function(c){var a=m(),b=c.messages,g=c.script,d=c.trigger_sync,e=function(){b.flags.modification||P.dropAll(g.uuid);a.notify();var c=l.doModify(g.uuid,g,d)||{};!b.flags.install&&!b.flags.update||
b.flags.factory||b.flags.reset||L.tS(g.name,g.fileURL,b.flags.install?"i":"u");(b.flags.first_install||b.flags.factory)&&z.setStorageByUid(g.uuid,{ts:Date.now()});return c},h={lastModified:void 0,installed:!0,renamed:b.flags.renamed};b.warnings.length||b.flags.ask?X.install(c).done(function(b){b.ok&&e();h.installed=b.ok;h.aborted=b.aborted;a.resolve(h)}).fail(function(b){a.reject(b)}):window.setTimeout(function(){e();a.resolve(h)},1);return a.promise()},h=w.getDebouncer(1E3),l={determineSourceURL:function(c){return c?
w.select([c.downloadURL,c.fileURL],function(a){if(!a||"file:"!==A.parse(a).protocol)return a})[0]:null},determineMetaURL:function(c){if(!c)return null;var a,b=x.determineOrigin(c);b&&b.meta_header?a=c.fileURL:!c.fileURL||b&&!b.meta_url||(a=c.fileURL.replace(".user.js",".meta.js"),c.fileURL==a&&(a=c.fileURL.replace(".tamper.js",".meta.js")),c.fileURL==a&&(a=null));return w.select([c.updateURL,c.downloadURL,a],function(a){if(!a||"file:"!==A.parse(a).protocol)return a})[0]},mergeCludes:function(c){var a,
b,g=c.options.override;["includes","excludes","matches"].forEach(function(a){c[a]=g["merge_"+a]&&g["orig_"+a]?g["orig_"+a].slice():[]});if(g.use_includes)for(a=0;a<g.use_includes.length;a++)b=c.excludes.indexOf(g.use_includes[a]),0<=b&&c.excludes.splice(b,1),c.includes.push(g.use_includes[a]);if(g.use_matches)for(a=0;a<g.use_matches.length;a++)b=c.excludes.indexOf(g.use_matches[a]),0<=b&&c.excludes.splice(b,1),c.matches.push(g.use_matches[a]);if(g.use_excludes)for(a=0;a<g.use_excludes.length;a++)c.excludes.push(g.use_excludes[a]);
return c},doSave:function(c){return u(c).then(e)},doRemove:function(c,a){z.removeByUid(c,a);z.setStorageByUid(c,null);P.dropAll(c);return m.Pledge()},doModify:function(c,a,b){void 0===b&&(b=!0);z.setByUid(c,a,b);return b?P.loadResources(c,a.resources).then(function(){return P.loadRequires(c,a.requires)}).then(function(){var b=[].concat(a.resources).concat(a.requires).map(function(a){return A.sanitize(a.unsafe_url,a.abs_url)});return P.dropAllBut(c,b)}):m.Pledge()},exportToJson:function(c,a){var b=
m(),g=x.determineScriptsToRun(null);c&&(g=w.select(g,function(a){return c[a.uuid]}));g=wa(g,{options_page:!0,externals:a.externals});a&&!a.storage||g.forEach(function(a){a.storage=z.getStorageByUid(a.uuid)});g={scripts:g};if(!a||a.global_settings)g.global_settings=r.getValue(p.CONSTANTS.STORAGE.CONFIG,{});b.resolve(g);return b.promise()},importFromJson:function(c){if(!c||!c.scripts||!c.scripts.length)return m.Breach();for(var a={},b=[],g={},d={requires:{},resources:{}},h=0,f;f=c.scripts[h];h++)try{var l=
m();"new-user-script"!=f.uuid&&(f.storage&&(g[f.uuid]=f.storage),["resources","requires"].forEach(function(a){var b;if(b=f[a])d[a][f.uuid]=b}),u({uuid:f.uuid,name:f.name,src:f.source,force_settings:{enabled:f.enabled,position:f.position},force_options:f.options,force_meta:{lastModified:f.lastModified},replace:!0,url:f.file_url||f.update_url,ask:!1}).done(function(b){a[w.createUUID()]=b;l.resolve()}).fail(function(a){n.warn("import: Error @ script",f.name,a);l.resolve()}),b.push(l.promise()))}catch(F){n.warn("import: Error while importing script",
f.name,F)}var q=function(){var a=m();m.when(b).always(function(){a.resolve()});return a.promise()}().then(function(){return X.import(a,c.global_settings)}).then(function(b){var c=m(),h=[],f=[];if(b.ok)for(var v=0,t;t=b.import_ids[v];v++)(function(){var b=t;if(a[b]){a[b].messages.warnings=[];var c=a[b].script.uuid,b=e(a[b]).progress(function(){["resources","requires"].forEach(function(a){var b;(b=d[a][c])&&b.length&&b.forEach(function(a){P.setElement(c,a.url,{content:a.content||"",meta:a.mimetype||
"text/javascript"},a.modified)})})}).done(function(){var a;g[c]&&(a=z.setStorageByUid(c,{data:g[c].data||{},ts:Date.now()}),f.push(a))});h.push(b)}})();m.when(h).always(function(){x.reorderScripts();m.when(f).always(function(){c.resolve(b)})});return c.promise()}).then(function(a){return c.global_settings&&a.global_settings?(a=r.setValue(p.CONSTANTS.STORAGE.CONFIG,c.global_settings).then(function(){q.done(function(){window.setTimeout(V.reset,1)});return m.Pledge({global_settings:!0})}),r.setTemporary(!0),
a):m.Pledge({})});return q},installFromUrl:function(c,a,b){var g=m(),k,e={messages:{errors:[d.getMessage("Unable_to_load_script_from_url_0url0",c)],warnings:[]}};a=a||{};b=b||{};var f=["url",c,JSON.stringify(a)].join("_");if(h.is(f))return n.debug("scriptman: de-bounced installFromUrl",c),m.Breach();h.add(f);if((k=A.parse(c))&&k.protocol.match(/(https?|file):/))"file:"!=k.protocol||p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS||n.warn("scriptman: Access to local files is forbidden! Loading the following script for installation may fail:",
c,"-> more info:","https://www.tampermonkey.net/faq.php#Q204");else return n.warn("scriptman: can't install from ",c),m.Breach(e);ca.getScriptFromURL(c).then(function(d){var k={url:c,src:d,ask:!0,replace:!0};a&&w.each(a,function(b,c){k[c]=a[c]});g.consume(l.installFromSource(d,k,b))}).fail(function(a){a?("file:"!=k.protocol||p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS||e.messages.warnings.unshift(d.getMessage("Tampermonkey_has_no_file_access_permission_")),e.heading=d.getMessage("You_are_about_to_install_a_UserScript_"),
b.silent_fail?g.reject(e):X.installError(e).always(function(a){g.reject(a)})):g.reject()});return g.promise()},installFromSource:function(c,a,b){var g=m(),k={src:c,ask:!0,replace:!0};a&&w.each(a,function(b,c){k[c]=a[c]});l.doSave(k).done(function(a){g.resolve(a.installed)}).fail(function(a){a?(a.heading=d.getMessage("You_are_about_to_install_a_UserScript_"),b.silent_fail?g.reject(a):X.installError(a).always(function(a){g.reject(a)})):g.reject()});return g.promise()},determineLastPosition:function(){var c=
0;z.getUidList().forEach(function(a){var g=z.getByUid(a);g.script&&g.cond?g.script.position&&g.script.position>c&&(c=g.script.position):n.warn("scriptman: inconsistent script entry",a)});var a=new C.Script;a.position>c&&(c=a.position);return c},convertToRegExp:function(c,a){var b,g;try{a||"/"!=c.substr(0,1)?a?(g=A.getRegExpFromMatch(c),b=new RegExp(g)):(g=A.getRegExpFromInclude(c),b=new RegExp(g,"i")):(g=("^"==c.substr(1,1)?"":".*")+c.replace(/^\//g,"").replace(/\/$/g,"")+("$"==c.substr(-2,1)?"":
".*"),g=g.replace(/(\.\*){1,}/g,".*"),b=new RegExp(g,"i"))}catch(d){return n.warn("scriptman: invalid regexp ",c),!1}return b},matchUrl:function(c,a){return""===c.replace(a,"")},regexify:function(c,a){var b={},g={inc:"rinc",match:"rinc",exc:"rexc"};Object.keys(g).forEach(function(d){var e=c[d]&&c[d].length?c[d].map(function(a){return l.convertToRegExp(a,"match"===d)}).filter(function(a){return!1!==a}):null;if(e||a)b[g[d]]=(b[g[d]]||[]).concat(e||[])});return b},validUrl:function(c,a,b){var d=!1;if(a.rinc){if(a.rinc.every(function(a){return l.matchUrl(c,
a)?(n.debug('scriptman: @include "'+a+'" matched'+(b?" ("+b+")":'"')),d=!0,!1):!0}),!d)return d}else d=!0;a.rexc&&a.rexc.every(function(a){return l.matchUrl(c,a)?(n.debug('scriptman: @exclude "'+a+'" matched'+(b?" ("+b+")":'"')),d=!1):!0});return d},getEvilness:function(c){var a=0;return c.fileURL&&(a=G.getEvilnessOf(c.fileURL))||c.downloadURL&&(a=G.getEvilnessOf(c.downloadURL))||c.updateURL&&(a=G.getEvilnessOf(c.updateURL))?(n.debug("scriptman: found blacklisted script",c),a):0},blackCheckAll:function(){z.getUidList().forEach(function(c){var a=
z.getByUid(c);if(a.script&&a.cond){var b=x.getEvilness(a.script);if(b!==a.script.evilness){if(b||void 0!==a.script.evilness)n.debug("scriptman: write blacklist state of ",a.script.name,b),b&&L.tS(a.script.name,b,"b");a.script.evilness=b;l.doModify(c,a.script,!1)}}})},reorderScripts:function(c,a){var b=l.determineScriptsToRun();if(c)for(var d=0;d<b.length;d++){var k=b[d];k.uuid==c&&(k.position=Number(a)+(k.position<a?.5:-.5))}b=q(b);d=1;for(k=0;k<b.length;k++){var e=b[k];e.position=d++;l.doModify(e.uuid,
e,!1)}},getScriptHistoryForTab:function(c){if(E.get.empty(c.id))n.debug("bg: WARN: Tabs.get.urls["+c.id+"] is empty!");else return E.get.history(c.id);return{}},getUniqueScriptsForTab:function(c){var a={};E.get.empty(c.id)?n.debug("bg: WARN: Tabs.get.urls["+c.id+"] is empty!"):w.each(E.get.urls(c.id),function(b,c){if(T.isAllowed(c)){var d=Z.get(b.frameId,c);[d.runners,d.disabled,d.evilness].forEach(function(b){b.forEach(function(b){a[b.uuid]={script:b}})})}});return a},scriptWillRun:function(c,a){if(a&&
c){var b=M.items.regexp.get(c);if(!b){if(!(b=r.getValue(p.CONSTANTS.PREFIX.COND+c,null)))return;b=l.regexify(b,!0);M.items.regexp.set(c,b)}return!!l.validUrl(a,b,c)}},determineScriptsToRun:function(c,a){var b=[];n.debug("scriptman: determineScriptsToRun @"+c);z.getUidList().forEach(function(g){var k=!0,e=0;c&&(e=Date.now(),k=l.scriptWillRun(g,c),e=Date.now()-e);var h=z.getByUid(g);h.script&&h.cond?(a&&1E3<e&&(n.warn("scriptman: checking "+h.script.name+"'s ("+g+") includes and excludes took "+e+"ms!"),
O.all("status",{key:"slowdown",class:"warning",text:d.getMessage("Script_0name0_is_slowing_down_some_page_loads_",h.script.name),timeout:3E5})),k&&b.push(h.script)):n.warn("scriptman: inconsistent script entry",g,h)});return q(b)},isContexter:function(c){return c.options&&("context-menu"===c.options.run_at||null===c.options.run_at&&"context-menu"===c.options.override.orig_run_at)},determineOrigin:function(c){return l.determineOriginOfUrl(c.fileURL||c.downloadURL||c.updateURL)},determineOriginOfUrl:function(c){if(c){var a=
c.match(/https?:\/\/userscripts\.org\/scripts\/(source|version)\/([0-9]{1,9})\.user\.js/)||c.match(/https?:\/\/userscripts-mirror\.org\/scripts\/(source|version)\/([0-9]{1,9})\.user\.js/);if(a&&3==a.length)return{id:a[2],token:"uso",meta_url:!0,url:"http://userscripts-mirror.org/scripts/show/"+a[2],issue_url:"http://contactbyweb.com/userscripts-mirror"};if((a=c.match(/https?:\/\/greasyfork\.org\/scripts\/([^/]+)\/code\/.*\.user\.js/))&&2==a.length)return c=a[1],{id:c,token:"gf",meta_url:!0,url:"https://greasyfork.org/scripts/"+
c,issue_url:"https://greasyfork.org/scripts/"+c+"/feedback",updates_allowed:function(a){return!a.match(/https?:\/\/greasyfork\.org\/scripts\/([^/]+)\/code\/.*\.user\.js.*version=[0-9]+.*/)}};if((a=c.match(/https?:\/\/openuserjs\.org\/install\/([^/]+)+\/(.*)\.user\.js/))&&3==a.length)return a.shift(),{id:a.join("/"),token:"ouj",meta_header:!0,url:"https://openuserjs.org/scripts/"+a[0]+"/"+a[1],issue_url:"https://openuserjs.org/scripts/"+a[0]+"/"+a[1]+"/issues"};if((a=c.match(/https?:\/\/monkeyguts\.com\/(codepages\/)?([0-9]{1,9})\.user\.js/))&&
3==a.length)return c=a[2],{id:c,token:"mog",meta_url:!0,url:"https://monkeyguts.com/code.php?id="+c,issue_url:"https://monkeyguts.com/code.php?nav=rev&id="+c};if((a=c.match(/https?:\/\/raw\.githubusercontent\.com\/([^/]+)\/([^/]+)\/.*\.user\.js/)||c.match(/https?:\/\/github\.com\/([^/]+)\/([^/]+)\/raw\/.*\.user\.js/)||c.match(/https?:\/\/github\.com\/([^/]+)\/([^/]+)\/releases\/download\/.*\.user\.js/))&&3==a.length)return a.shift(),c=a.join("/"),{id:c,token:"gh",url:"https://github.com/"+c,issue_url:"https://github.com/"+
c+"/issues"};if((a=c.match(/https?:\/\/gitlab\.com\/([^/]+\/?[^/]*)\/([^/]+)\/raw\/.*\.user\.js/))&&3==a.length)return a.shift(),c=a.join("/"),{id:c,token:"gl",url:"https://gitlab.com/"+c,issue_url:"https://gitlab.com/"+c+"/issues"};if((a=c.match(/https?:\/\/bitbucket\.org\/([^/]+)\/([^/]+)\/(?:raw|downloads)\/.*\.user\.js/))&&3==a.length)return a.shift(),c=a.join("/"),{id:c,token:"bb",url:"https://bitbucket.org/"+c,issue_url:"https://bitbucket.org/"+c+"/issues"};if((c=c.match(/https?:\/\/userstyles\.org\/styles\/userjs\/([^/]+)\/.*\.user\.js/))&&
2==c.length)return c.shift(),{id:c[0],token:"usty",url:"https://userstyles.org/styles/"+c[0],issue_url:"https://forum.userstyles.org/post/discussion?Discussion/StyleID="+c[0],convert:function(a){var c,k,e,h,f=[{tag:"includes",re:/(?: \|\| \(new RegExp\("\^)([^$]+)(?:\$"\)\)\.test\(document\.location\.href\))/g,idx:1,value:function(a){return"/^"+a.replace(/\\\\(.)/g,"\\$1")+"$/"}},{tag:"includes",re:/(?: \|\| \(document\.location\.href\.indexOf\(")([^\"]+)"(?:\) == 0\))/g,idx:1,value:function(a){return a+
"*"}},{tag:"matches",re:/(?: \|\| \(document\.domain == ")([^\"]+)"(?: \|\| document\.domain\.substring\(document\.domain\.indexOf\("[^\"]+"\) \+ 1\) == "[^\"]+"\))/g,idx:1,value:function(a){return"*."+a}}],l=new RegExp("(?:if \\(false)("+f.map(function(a){return"(?:"+a.re.source+")"}).join("|")+")+","g");0===a.includes.length&&0===a.matches.length&&0===a.excludes.length&&a.options&&a.options.override&&a.options.override.orig_includes&&0===a.options.override.orig_includes.length&&a.options.override.orig_matches&&
0===a.options.override.orig_matches.length&&(k=a.textContent.match(l))&&(k.forEach(function(c){f.forEach(function(d){for(;e=d.re.exec(c);)if(e.length>d.idx){var g=d.value(e[d.idx]);a.options.override["orig_"+d.tag].push(g);a[d.tag].push(g);h=!0}})}),h&&(c=d.getMessage("Automatically_added_user_includes_for_compatibility_reasons_")));return{script:a,warning:c}}}}},clean:function(c){z.getUidList().forEach(function(a){var b=z.getByUid(a);if(!b.script||!b.cond){if(c)return n.warn("scriptman: inconsistent script entry",
a,b);l.doRemove(a,!0)}})}};return l}();scma=x;var z=function(){var d=[],u={init:function(){r.addDifferentOriginChangeListener(p.CONSTANTS.PREFIX.STORE,function(d,h){if(h&&h.hasOwnProperty("value")&&h.origin){var f=d.replace(p.CONSTANTS.PREFIX.STORE,""),c;for(c in h.value.data)h.value.data.hasOwnProperty(c)&&function(){var a=c,b=h.value.data[c];u.notifyStorageListeners({uuid:f},null,function(c){var d={data:{},ts:0};d.data[a]=b;d.ts=h.value.data.ts;var e={storage:d};void 0===d.data[a]&&(e.removed=a);
c(e)})}()}})},getUidList:function(){var d=new RegExp("^"+p.CONSTANTS.PREFIX.SCRIPT_UID),h=[];r.listValues().forEach(function(f){-1!=f.search(d)&&h.push(f.replace(d,""))});return h},getUidsByName:function(d,h){var f=[];u.getUidList().forEach(function(c){var a=u.getMetaByUid(c);!a||a.name!=d||h&&h!=a.namespace||f.push(c)});return f},getUidByName:function(d){return u.getUidsByName(d)[0]},getStorageByUid:function(d){d=r.getValue(p.CONSTANTS.PREFIX.STORE+d,{ts:0,data:{}});"undefined"===typeof d.ts&&(d.ts=
0);"undefined"===typeof d.data&&(d.data={});return d},setStorageByUid:function(d,h){return h?r.setValue(p.CONSTANTS.PREFIX.STORE+d,h):r.deleteValue(p.CONSTANTS.PREFIX.STORE+d)},getMetaByUid:function(d){return r.getValue(p.CONSTANTS.PREFIX.META+d,null)},getByUid:function(d,h){if(!d)return n.error("sb: no UUID set"),{};var f,c=r.getValue(p.CONSTANTS.PREFIX.META+d,null);if(c){var a=function(a){if(a)for(var c=0,d=null;d=a[c];c++)delete d.loaded,delete d.textContent,delete d.resURL,delete d.resText};a(c.requires);
a(c.resources);c.uuid=d;c.grant=c.grant||[];c.options.override.use_connects||(c.connects=c.connects||[],c.options.override.merge_connects=!0,c.options.override.use_connects=[]);void 0===c.options.check_for_updates&&(c.options.check_for_updates=!0);h&&(c=w.copy(c,{}));c.textContent=r.getValue(p.CONSTANTS.PREFIX.SCRIPT+d,c.textContent);c.textContent&&(f=c)}return{script:f,cond:r.getValue(p.CONSTANTS.PREFIX.COND+d,null)}},setByUid:function(d,h,f){var c={};if(!d)return n.error("sb: no UUID set",h),c;
if(null===h.textContent||void 0===h.textContent)throw Error("No script code set!");var a=r.getValue(p.CONSTANTS.PREFIX.META+d),b=!a,g={},k=w.copy(h,{});k.textContent=null;g[p.CONSTANTS.PREFIX.META+d]=k;g[p.CONSTANTS.PREFIX.SCRIPT_UID+d]=h.name;g[p.CONSTANTS.PREFIX.COND+d]={inc:h.includes,match:h.matches,exc:h.excludes};g[p.CONSTANTS.PREFIX.SCRIPT+d]=h.textContent;f&&!p.DB.SECURE&&h.evilness!=G.SEVERITY_FOISTED_SCRIPT&&(g[p.CONSTANTS.PREFIX.SEC+d]=da.createHash(h.textContent));r.setValues(g);f&&(pa.onScriptsChanged(),
b?N.scriptAddedCb(h.name,h):N.scriptChangedCb(h.name,h,a));M.items.rundata.removeAll();M.items.regexp.remove(d);return c},removeByUid:function(d,h){void 0===h&&(h=!0);var q=u.getByUid(d);r.deleteValue(p.CONSTANTS.PREFIX.SCRIPT_UID+d);r.deleteValue(p.CONSTANTS.PREFIX.COND+d);r.deleteValue(p.CONSTANTS.PREFIX.SCRIPT+d);r.deleteValue(p.CONSTANTS.PREFIX.META+d);r.deleteValue(p.CONSTANTS.PREFIX.STORE+d);h&&(pa.onScriptsChanged(),q.script&&q.cond&&(N.scriptRemovedCb(q.script.name,q.script),f.values&&L.tS(q.script.name,
null,"r")));M.items.rundata.removeAll();M.items.regexp.remove(d);return{}},addStorageListener:function(e,h,f,c,a){d.push({tabid:e,id:h,uuid:f,time:c,response:a})},removeStorageListeners:function(e,h){void 0===h&&(h=!0);var f=d;d=[];f.forEach(function(c){try{void 0!==e.tabid&&e.tabid!==c.tabid||void 0!==e.uuid&&e.uuid!==c.uuid||void 0!==e.id&&e.id!==c.id?d.push(c):h&&c.response({})}catch(a){n.debug("sb: listener clear for script",e,"failed! Page reload?!")}})},notifyStorageListeners:function(e,h,f){e=
e||{};h=h||{};d.forEach(function(c){try{void 0!==h.uuid&&c.uuid===h.uuid||void 0!==h.tabid&&c.tabid===h.tabid||void 0!==h.id&&c.id===h.id||void 0!==e.tabid&&e.tabid!==c.tabid||void 0!==e.uuid&&e.uuid!==c.uuid||void 0!==e.id&&e.id!==c.id||f&&f(c.response)}catch(a){n.warn("sb: listener notification for script",e,"failed! Page reload?!")}})}};return u}();scbr=z;var da=function(){var d,f,e,h,l=function(){z.getUidList().forEach(function(a){a=z.getByUid(a);a.script&&a.cond&&a.script.evilness!=G.SEVERITY_FOISTED_SCRIPT&&
(n.warn("content security: found unfamiliar script",a.script.name),r.deleteValue(p.CONSTANTS.PREFIX.SEC+a.script.uuid),L.tS(a.script.name,a.script.fileURL||a.script.downloadURL||a.script.updateURL,"f"))})},c=function(){z.getUidList().forEach(function(a){a=z.getByUid(a);a.script&&a.cond&&a.script.evilness!=G.SEVERITY_FOISTED_SCRIPT&&(n.debug("content security: saltify",a.script.name),r.setValue(p.CONSTANTS.PREFIX.SEC+a.script.uuid,da.createHash(a.script.textContent)))})},a=function(){z.getUidList().forEach(function(a){var b=
z.getByUid(a);if(b.script&&b.cond&&b.script.evilness!=G.SEVERITY_FOISTED_SCRIPT){var c=r.getValue(p.CONSTANTS.PREFIX.SEC+b.script.uuid,null);c&&"sha256="===c.substr(0,7)&&k.createHash(b.script.textContent)===c||(n.debug("content security: script content hash error",b.script.name,c),b.script.evilness=G.SEVERITY_FOISTED_SCRIPT,L.tS(b.script.name,b.script.fileURL||b.script.downloadURL||b.script.updateURL,"w"),x.doModify(a,b.script,!1))}});return m.Pledge()},b=function(a){f=f||a||"timeout";d&&(d.resolve(),
d=null)},g=function(){e=w.createUUID();r.secure.cookie.setValue("salt",e);n.debug("content security: creating a new salt "+e.substr(0,4)+"...")},k={init:function(){var a=m();if(p.DB.SECURE)a.resolve();else if(rea.extension.inIncognitoContext)a.resolve();else{e=r.secure.cookie.getValue("salt");var c,g,k;c=g=k="unknown";try{k=navigator.language||k}catch(l){}try{c=(navigator.userAgent.match(/\((.*?)\)/)||{})[1]||c}catch(l){}try{g=navigator.hardwareConcurrency||g}catch(l){}h=[c,g,k].join("-");e?a.resolve():
f?a.resolve():(window.setTimeout(b,1E4),d=a)}return a.promise()},check:function(){var b=m();p.DB.SECURE?b.resolve():rea.extension.inIncognitoContext?b.resolve():("install"==f?l():"update"!=f||e||(g(),c()),e||g(),"dhdg"===rea.runtime.short_id?b.resolve():a().always(b.resolve));return b.promise()},onInstalled:function(){p.DB.SECURE||b("install")},onUpdated:function(){p.DB.SECURE||b("update")},createHash:function(a){return"sha256="+forge_sha256(h+e+a)}};return k}(),Ca=function(){var q={ping:{allow:{insecure:!0},
exec:function(a,b,c){c({pong:!0,instanceID:Aa,config:{layout:f.values.layout}})}},newTab:{allow:{extpage:!0},exec:function(a,b,c){("options"==b.extpage||"options"==a.origin?m.Pledge(b.tab):sa()).then(function(b){rea.tabs.create({url:a.url,parent:b},function(a){c({tabId:a.id})})})}},tabs:{allow:{script:!0},exec:function(a,b,c){"get"==a.action?b.tab&&a.uuid?c({data:qa.get(b.tab.id,a.uuid)}):(n.warn("bg: unable to process request",b,a),c({data:null})):"list"==a.action?a.uuid?c({data:qa.getAll(a.uuid)}):
(n.warn("bg: unable to process request",b,a),c({data:null})):"set"==a.action?(b.tab&&a.uuid?qa.set(b.tab.id,a.uuid,a.tab):n.warn("bg: unable to process request",b,a),c({})):c({error:"unknown action"})}},focusTab:{allow:{script:!0},exec:function(a,b,c){(a=b&&b.tab?b.tab.id:null)?rea.tabs.update(a,{active:!0},function(){c({error:rea.runtime.lastError})}):c({error:"internal error"})}},closeTab:{allow:{script:!0},exec:function(a,b,c){var d=b&&b.tab?b.tab.id:null;d?rea.tabs.query({windowType:"normal"},
function(a){1>=a.length?(n.warn("bg:","refused to close last tab!"),c({error:"refused to close last tab!"})):rea.tabs.remove(d,function(){c({})})}):c({error:"internal error"})}},setOption:{allow:{extpage:!0},exec:function(a,b,c){var d="options"==b.extpage||"options"==a.origin;f.setValue(a.name,a.value).always(function(){d?U.create("options.settings").done(function(a){c({items:a,options:f.snapshot})}).fail(function(a){c({error:a,options:f.snapshot})}):c({})})}},reportAnIssue:{allow:{extpage:!0},exec:function(a,
b,c){("options"==b.extpage||"options"==a.origin?m.Pledge(b.tab):sa()).then(function(b){var d,e,f,h;if(a.uuid&&(d=z.getByUid(a.uuid))&&d.script&&d.cond){e=x.determineOrigin(d.script);var q;if("hoster"==a.to&&e)f=e,h=[f.token,f.id].join(":");else if(q=d.script.supportURL||e.issue_url||e.url)f={issue_url:q},h=e?[a.to,e.token,e.id].join(":"):[a.to,f.url].join(":");f&&(L.tS(d.script.name,h,"m"),rea.tabs.create({url:f.abuse_url||f.issue_url,active:!0,parent:b},function(){}))}c({})})}},begEvent:{allow:{extpage:!0},
exec:function(a,b,c){if("dialog"==a.action)ea.dialog.shown(a.extra);else if("clicked"==a.action){var d,e;a.extra&&(d=a.extra.amount,e=a.extra.currency);ea.clicked(a.type,d,e)}else if(ea.button[a.action])ea.button[a.action](a.type,a.extra);else n.warn("bg: Warning: unknown request ",a);c({})}},buttonPress:{allow:{extpage:!0},exec:function(a,b,c){b=function(){c({})};if("reset_simple"==a.name)V.reset(b);else if("reset_factory"==a.name)V.factoryReset(b);else if("reset_sync"==a.name)N.reset().always(b);
else if("install_tests"==a.name)(b=xa.framework.prepare(x.doSave,p.RUNTIME.BROWSER,p.RUNTIME.BROWSER_VERSION,b))&&n.error(b);else if("enabled"==a.name)f.setValue(a.name,!f.values[a.name]).always(function(){c({})});else if("installFromUrl"==a.name)x.installFromUrl(a.data).always(function(){c({})});else if("externals_delete"==a.name)P.cleanElement(a.scriptuid,a.safe_url),U.create("options.scripts").done(function(a){c({items:a,options:f.snapshot})}).fail(function(a){c({error:a,options:f.snapshot})});
else if("focus_tab"==a.name)q.focusTab.exec({},{tab:{id:a.tabid}},c);else if("run_script_updates"==a.name)if(a.scriptuid){var d;ca.check(!0,!1,a.scriptuid).done(function(a){d=a}).always(function(){c({scriptuid:a.scriptuid,updatable:d})})}else ca.check(!0,!0),c({});else n.warn("bg: Warning: unknown button "+a.name),c({})}},loadTree:{allow:{extpage:!0},exec:function(a,b,c){U.create(a.referrer,{complete:a.complete,url:a.url,uuid:a.uuid,filter:a.filter,tabId:a.tabId}).done(function(b){b={items:b,i18n:f.values.i18n,
options:f.snapshot,xhr:W.getConfig(),begging:ea.needed()};a.layout&&(b.layout=ma.getLayoutByValue(f.values.layout));c(b)}).fail(function(a){c({error:a,options:f.snapshot})})}},modifyScriptOptions:{allow:{extpage:!0},exec:function(a,b,c){if(a.uuid){var d="options"==b.extpage||"options"==a.origin,e=void 0==a.reload||1==a.reload,h=!1,l=z.getByUid(a.uuid,!0);if(l.script&&l.cond){var u=!1,m=new C.Script;Object.keys(m.options).forEach(function(b){void 0!==a[b]&&(l.script.options[b]=a[b],h|=!0===N.SYNCED[b])});
Object.keys(m.options.override).forEach(function(b){-1!=b.search("merge_")&&void 0!==a[b]&&(l.script.options.override[b]=a[b],u=!0)});["includes","excludes","matches"].forEach(function(b){void 0!==a[b]&&(u=!0,l.script.options.override["use_"+b]=a[b])});["connects","blockers"].forEach(function(b){void 0!==a[b]&&(l.script.options.override["use_"+b]=a[b])});a.add_excludes&&(l.script.options.override.use_excludes=l.script.options.override.use_excludes.concat(a.add_excludes),u=!0);u&&(l.script=x.mergeCludes(l.script));
a.temp_connects&&ja.setSessionConnects(l.script.uuid,a.temp_connects);void 0!==a.enabled&&(l.script.enabled=a.enabled);h&&(l.script.lastModified=Date.now());void 0!==a.file_url&&(l.script.downloadURL=a.file_url);x.doModify(l.script.uuid,l.script,h).done(function(){e?(void 0!==a.position&&x.reorderScripts(a.uuid,a.position),d?q.loadTree.exec({referrer:"options.scripts"},b,c):rea.tabs.getSelected(null,function(b){U.create("actions").done(function(a){c({items:a,i18n:f.values.i18n,options:{enabled:f.values.enabled,
layout:f.values.layout}})}).fail(function(){c({i18n:f.values.i18n,options:{enabled:f.values.enabled,layout:f.values.layout}})});a.uuid&&f.values.autoReload&&rea.tabs.sendMessage(b.id,{method:"reload",frameId:0},function(){})})):c({})}).fail(function(){c({})})}else c({})}else c({})}},modifyNativeScript:{allow:{extpage:!0},exec:function(a,b,c){if(a.nid){var k=void 0==a.reload||1==a.reload;Q.getUserscriptById(a.nid).then(function(c){if(c)if("installed"==a.actionid){if("false"==a.value)return Q.uninstall(c)}else{if("enabled"==
a.actionid)return Q.setEnabled(c,a.value);if("imported"==a.actionid&&"true"==a.value){var g=Q.getUserscriptSource(c);if(g)return x.doSave({src:g,ask:!0,replace:!0}).then(function(a){if(a.installed){if("disable"==f.values.native_import_post_action)return Q.setEnabled(c,!1);if("uninstall"==f.values.native_import_post_action)return Q.uninstall(c)}});rea.tabs.sendMessage(b.tab.id,{method:"showMsg",msg:d.getMessage("Please_double_check_the_native_script_import_settings__")},function(){})}}else k=!1;return m.Pledge()}).always(function(){k?
q.loadTree.exec({referrer:"options.scripts"},b,c):c({})})}else c({})}},saveScript:{allow:{extpage:!0},exec:function(a,b,c){var k=void 0===a.reload||!!a.reload,e=function(a){k?U.create("options.scripts").done(function(b){a.items=b;a.options=f.snapshot;c(a)}).fail(function(a){c({error:a,options:f.snapshot})}):c({})};if(a.clean){n.debug("bg: clean userscript "+a.uuid);b=z.getByUid(a.uuid);var h=function(b){U.create("options.scripts").done(function(d){c({cleaned:b.installed,items:d,options:f.snapshot});
b.installed&&z.notifyStorageListeners({uuid:a.uuid},null,function(b){b({storage:z.getStorageByUid(a.uuid)})})}).fail(function(a){c({error:a,options:f.snapshot})})};b.script&&b.cond?x.doSave({name:a.name,uuid:a.uuid,src:b.script.textContent,clean:!0,ask:!1,internal:!0,save:!0}).always(function(a){h(a||{installed:!1})}):(n.error(d.getMessage("fatal_error")+" ("+a.uuid+")!!!"),h({installed:!1}))}else if(a.code){var l=c;k&&(l=function(a){x.reorderScripts();e(a)});a.new_script&&(a.uuid=w.createUUID());
x.doSave({name:a.name,uuid:a.uuid,force_url:a.force_url,src:a.code,ask:!f.values.editor_easySave,lastModTime:a.lastModTime,save:!0}).always(function(a){l(a||{installed:!1})})}else a.auto_save||(x.doRemove(a.uuid),x.reorderScripts()),e({})}},saveExternal:{allow:{extpage:!0},exec:function(a,b,c){P.setElement(a.uuid,a.url,{content:a.code||"",meta:a.mimetype||"text/javascript"},!0);U.create("options.scripts").done(function(a){c({success:!0,items:a,options:f.snapshot})}).fail(function(a){c({error:a,options:f.snapshot})})}},
saveStorageKey:{allow:{extpage:!0},exec:function(a,b,c){h.saveStorageKey.exec(null,a,b,c)}},exportToJson:{allow:{extpage:!0},exec:function(a,b,c){x.exportToJson(a.ids,a.options).done(function(a){c({json:a})}).fail(function(){c({})})}},importFromJson:{allow:{extpage:!0},exec:function(a,b,c){var e=void 0===a.reload||!!a.reload;x.importFromJson(a.json).fail(function(a){c({error:a||d.getMessage("An_error_occured_during_import_")})}).done(function(a){var b={reload:a.global_settings};e&&!b.reload?U.create("options.scripts").done(function(a){b.items=
a;b.options=f.snapshot;c(b)}).fail(function(a){c({error:a,options:f.snapshot})}):c(b)})}},download:{allow:{extpage:!0},exec:function(a,b,c){h.download.exec(null,a,b,function(a){(a.error||a.load)&&c(a)})}},askCom:{allow:{extpage:!0},exec:function(a,b,c){X.onMessage(a.data).always(function(b){b.i18n=f.values.i18n;b.options=f.snapshot;b.ext={version:rea.extension.manifest.version};a.data.layout&&(b.layout=ma.getLayoutByValue(f.values.layout));c(b)})}},installScript:{allow:{extpage:!0},exec:function(a,
b,c){if(b.tab){var e={};x.installFromUrl(a.url,{},{silent_fail:!0}).done(function(a){e={data:null,found:!0,installed:a}}).fail(function(a){e.err=a&&a.messages&&a.messages.errors?a.messages.errors[0]:d.getMessage("Unable_to_parse_this_")}).always(function(){c(e)})}else n.warn("bg: Error: unable to install script due to empty tabID!")}},execMenuCmd:{allow:{extpage:!0},exec:function(a,b,c){(a=fa.getById(a.id))?a.response({run:!0,menuId:a.id}):n.warn("bg: Error: unable to find MC id "+a.id);c({})}},unLoad:{allow:{script:!0},
exec:function(a,b){a.topframe||a.id&&b.frameId&&E.events.unload(b.tab.id,b.frameId,a.id);return!1}},prepare:{allow:{script:!0},exec:function(a,b,c){if(b.tab){var d=void 0!==b.frameId?b.frameId:a.topframe?0:null,e=A.woHash(a.url);a.cleanup?(E.events.clean(b.tab.id,d,e),R.setIcon(b.tab.id),R.setBadge(b.tab.id),c({})):E.events.run(b.tab.id,d,a.id,e,function(d){d=d?Z.answer(d,a.url):{fast:!0};c(d);R.setIcon(b.tab.id);R.setBadge(b.tab.id)})}else c({})}},notification:{allow:{script:!0,extpage:!0},exec:function(a,
b,c){var d=a.image?a.image:rea.extension.getURL("images/icon128.png");(function(){var c=m();a.highlight&&b.tab?S.highlight(b.tab.id,c.resolve):c.resolve();return c.promise()})().then(function(){var b=m();a.text?S.show(a.title,a.text,d,a.timeout,b.resolve):b.resolve();return b.promise()}).always(function(a){c({clicked:a&&a.clicked})})}},determineScriptsToRun:{allow:{extpage:!0},exec:function(a,b,c){c({scripts:x.determineScriptsToRun(a.url).map(function(a){return a.uuid})})}},syntaxCheck:{allow:{script:!0,
extpage:!0},exec:function(a,b,c){(function(){var a=m();Registry.require("hinter",function(){a.resolve(Registry.get("hinter"))});return a.promise()})().then(function(b){return b.hint(a.code,f.values.editor_linter_config||void 0)}).always(function(a){c({errors:a})})}},externalMessage:{allow:{insecure:!0},exec:function(a,b,d){a=a.request;var e;if("off"!=f.values.external_connect&&(e=b.url)&&T.isAllowed(e)){for(var h,l,q,u=Object.keys(c.externally_connectable),m=0;m<u.length;m++)if(h=u[m],b=c.externally_connectable[h],
(l=x.regexify({match:[h]}))&&x.validUrl(e,l)&&(-1!=b.indexOf("*")||-1!=b.indexOf(a.method))){q=!0;break}if(q)if("getVersion"==a.method)d({version:rea.extension.manifest.version,id:rea.runtime.short_id});else if("all"!=f.values.external_connect)n.warn("mh: calling external method "+a.method+" is not permitted to "+e+" by the user");else if("isInstalled"==a.method){var p,r,w,A;e=!1;l=a.script.name;(r=z.getUidsByName(l,a.script.namespace)[0])&&(p=z.getByUid(r))&&p.script&&(e=!0,A=p.script.enabled,w=
p.script.version);d({name:l,installed:e,enabled:A,version:w})}else n.warn("mh: unknown external method "+a.method);else n.warn("mh: calling external method "+a.method+" is not permitted to "+e)}}},cookie:{allow:{script:!0},exec:function(a,b,c){var d="expirationDate domain httpOnly secure session name path sameSite value".split(" ").concat(["url"]),e=d.concat(["hostOnly"]);b=a.url||b.url||null;b=a.details.url?A.sanitize(a.details.url,b)||a.details.url:b;if(a)c({data:{error:"not supported"}});else if(b)if(T.isAllowed(A.woHash(b)))if(x.scriptWillRun(a.uuid,
b))if("list"==a.action)ua.getAll({url:b,domain:a.details.domain,name:a.details.name,path:a.details.path}).done(function(a){a=a.map(function(a){var b={};e.forEach(function(c){b[c]=a[c]});return b});c({data:{cookies:a}})});else if("delete"==a.action)ua.remove({url:b,name:a.details.name}).done(function(){c({data:{success:!0}})}).fail(function(a){c({data:{error:a}})});else if("set"==a.action){var h={},f=a.details;d.forEach(function(a){void 0!==f[a]&&(-1!=["value","name"].indexOf(a)?h[a]=String(f[a]):
h[a]=f[a])});h.url=h.url||b;ua.set(h).done(function(){c({data:{success:!0}})}).fail(function(a){c({data:{error:a}})})}else c({data:{error:"unknown action"}});else c({data:{error:"the URL needs to be included by the scripts @include or @match tag"}});else c({data:{error:"the URL is filtered by the security settings"}});else c({data:{error:"invalid URL"}})}},api:{allow:{script:!0},exec:function(a,b,c){L.tA(a.name,a.type);c()}}},u=function(a){var b=rea.runtime.id,b=!p.REQUESTS.HAS_SENDER_ID&&a.tab||
a.id===b,c=null,d=p.REQUESTS.INTERNAL_PAGE_PROTOCOL+"//",e=p.REQUESTS.GET_INTERNAL_PAGE_REGEXP();a=a.url?a.url:a.tab?a.tab.url:null;if(d=b&&(a?0==a.search(d):!0))a?(e=a.match(e))&&2==e.length&&(c=e[1]):c="*";return{id_valid:b,url:a,page:c,extpage:d}},e=function(a,b,c){if(!I.late)return I.registerLateCallback(function(){e(a,b,c)}),!0;var d=q[a.method];if(!d)return n.warn("mh: unknown method "+a.method),!1;if(!d.allow||!d.exec)return n.warn("mh: invalid implementation of "+a.method),!1;var h=u(b),f=
h.extpage,l=h.page,h=h.id_valid;f?b.extpage=l:delete a.origin;var m="options"==l,p=!0;if("background"==l||d.allow.insecure||d.allow.extpage&&f||d.allow.options&&m||d.allow.script&&h&&!f){if(d=d.exec(a,b,function(a){p=!1;c(a)}),!1!==p&&!1!==d)return!0}else return!1===a.topframe&&(f||m)||n.warn("mh: this context doesn't have the permission to call \""+a.method+'"'),!1},h={xhr:{allow:{script:!0},exec:function(a,b,c,d){var e=!1,h=function(){a.disconnect()};b.details.convertBinary=!0;b.details.partialSize=
b.details.partialSize||p.XMLHTTPREQUEST.PARTIAL_SIZE;var l={};Object.keys(b.callbacks).forEach(function(a){var c="ondone"===a;if(b.callbacks[a]||c||"onload"===a)l[a]=function(b){b={data:b.response,exception:b.exception};b[a]=!0;d(b);c&&h()}});l.ondone||(l.ondone=h);var q;b.details.url=A.sanitize(b.details.url,b.url||c.url||null)||b.details.url;p.RUNTIME.WEBREQUEST_XHR_SUPPORT&&"no"!=f.values.webrequest_modHeaders&&(b.details.headers=b.details.headers||{},b.details.headers.internal=b.uuid,p.REQUESTS.SENDS_ORIGIN&&
-1==Object.keys(b.details.headers).map(function(a){return a.toLowerCase()}).indexOf("origin")&&(b.details.headers.origin=null));(function(){return b.details.cookie&&b.details.url?ua.getAll({url:b.details.url}).then(function(a){a=a.map(function(a){return a.name+"="+encodeURIComponent(a.value)}).concat([b.details.cookie]).join(";");delete b.details.cookie;b.details.headers=b.details.headers||{};b.details.headers.cookie=a}):m.Pledge()})().then(function(){if(!e){var a;if(b.details.url&&(a=A.parse(b.details.url).protocol)&&
-1!=["file:",p.REQUESTS.INTERNAL_PAGE_PROTOCOL].indexOf(a)){var d=function(a){var c='Refused to connect to "'+b.details.url+'": '+a,d=W.makeErrorResponse(c);["onerror","ondone"].forEach(function(a){if(l[a])l[a]({response:d,exception:c})})};if("file:"==a){var h,k;p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS&&("all"==f.values.script_file_access?h=!0:"externals"==f.values.script_file_access&&(k=z.getByUid(b.uuid))&&k.script&&k.cond&&-1!=[].concat(k.script.resources).concat(k.script.requires).map(function(a){return A.sanitize(a.unsafe_url,
a.abs_url)}).indexOf(b.details.url)&&(h=!0));if(!h)return d("Access to this local file is forbidden!")}rea.file.get(b.details.url,function(a){var b={response_data:J.arrbuf2str(a),readyState:4,responseHeaders:"",status:0,statusText:""};["onload","ondone"].forEach(function(a){if(l[a])l[a]({response:b})})},d)}else q=ja.exec(b.details,b.uuid,c||{},l)}});return function(){e=!0;q&&q.abort()}}},download:{allow:{script:!0},exec:function(a,b,c,d){b=b.details;b.internal=null===a;var e=K.start(b,{onload:function(a){d&&
d({load:!0,data:a})},onprogress:function(a){d&&d({progress:!0,data:a})},onerror:function(a){d&&d({error:!0,data:a})},ontimeout:function(a){d&&d({timeout:!0,data:a})},ondone:function(){a&&a.disconnect();a=null}});a&&void 0!==e&&a.onMessage.addListener(function(a){a.cancel&&null!==e&&(K.cancel(e),e=null)});return function(){d=a=null}}},webRequest:{allow:{script:!0},exec:function(a,b,c,d){a=c.tab.id;c=c.frameId;(void 0!==a&&void 0!==c||!b.uuid)&&ia.scripts.set(a,c,b.uuid,b.rules,function(a){d(a)})}},
addStorageListener:{allow:{script:!0},exec:function(a,b,c,d){if(c.tab)return z.addStorageListener(c.tab.id,b.id,b.uuid,Date.now(),d),function(){z.removeStorageListeners({uuid:b.uuid,id:b.id},!1)};d({error:!0})}},saveStorageKey:{allow:{script:!0},exec:function(a,b,c,d){c.tab?b.uuid&&(a=z.getStorageByUid(b.uuid),a.data[b.key]=b.value,a.ts=b.ts,z.setStorageByUid(b.uuid,a),z.notifyStorageListeners({uuid:b.uuid},{id:b.id},function(a){var c={data:{},ts:0};c.data[b.key]=b.value;c.ts=b.ts;var d={storage:c};
void 0===c.data[b.key]&&(d.removed=b.key);a(d)})):n.warn("storage: unable to save storage due to empty tabID!");d({})}},openInTab:{allow:{script:!0},exec:function(a,b,c,d){var e=["active"],h={url:b.details.url},f=null;if(b=b.details.options){for(var l=0;l<e.length;l++)void 0!==b[e[l]]&&(h[e[l]]=b[e[l]]);b.insert&&(h.index=c.tab.index+1);b.setParent&&(h.parent=c.tab)}rea.tabs.create(h,function(b){f=b.id;a&&(ga[f]={onClose:function(){a&&d({closed:!0})}},d({success:!0,tabId:f}))});a.onMessage.addListener(function(a){if(null!==
f)if(a.close)rea.tabs.remove(f),f=null;else if(void 0!==a.name){var b=3,c=function(){E.listeners.once.whenReady(f,function(){rea.tabs.sendMessage(f,{method:"setForeignAttr",attr:"name",value:a.name},function(g){g?d({name:a.name}):0<b--?c():n.warn("foreignAttr: error setting attr")})})};c()}});return function(){null!==f&&delete ga[f];a=null}}},registerMenuCommand:{allow:{script:!0},exec:function(a,b,c,d){if(c.tab)return fa.add(c.tab.id,b.name,b.uuid,b.accessKey,b.menuId,d),O.actionPage("update"),function(){fa.clearById(b.menuId);
O.actionPage("update")};n.warn("Unable to register menu cmd due to empty tabID!");a.disconnect()}},tabWatch:{allow:{extpage:!0},exec:function(a,b,c,d){var e=ya.openAndWatch({url:b.url,index:(c.tab.index||0)+1,parent:c.tab},function(b){b?d({tab:b}):(h(),a.disconnect())}),h=function(){e.cancel()};return h}}},l=function(){var a=function(a,c){var d=a.sender,e=h[c.method];if(!e)return n.warn("mh: unknown method "+c.method),!1;if(!e.allow||!e.exec)return n.warn("mh: invalid implementation of "+c.method),
!1;var f=u(d),l=f.extpage,q=f.page,m="options"==q,f=f.id_valid&&!l;if("background"==q||e.allow.insecure||e.allow.extpage&&l||e.allow.options&&m||e.allow.script&&f)(d=e.exec(a,c,d,function(c){try{a.postMessage(c)}catch(d){n.debug("bg: Error sending port ("+a.name+") message",c)}}))&&a.onDisconnect.addListener(d);else return!1===c.topframe&&(l||m)||n.warn("mh: this context doesn't have the permission to call \""+c.method+'"'),!1};return function(c){I.late?c.onMessage.addListener(function(d){void 0!==
d.method&&a(c,d)}):I.registerLateCallback(function(){l(c)})}}(),c={init:function(){c.externally_connectable_reg=x.regexify({match:Object.keys(c.externally_connectable)});rea.extension.onMessage.addListener(e);rea.extension.onConnect.addListener(l);rea.extension.onConnectExternal.addListener(function(a){a.disconnect()})},externally_connectable:{"*://www.tampermonkey.net/*":["getVersion"],"https://greasyfork.org/*":["*"],"https://userstyles.org/*":["*"]}};return c}(),ua=function(){return{getAll:function(d){var f=
m();rea.cookies.getAll(d,f.resolve);return f.promise()},remove:function(d){var f=m();rea.cookies.remove(d,function(d){d?f.resolve():f.reject(rea.runtime.lastError||"unknown error")});return f.promise()},set:function(d){var f=m();rea.cookies.set(d,function(d){d?f.resolve():f.reject(rea.runtime.lastError||"unknown error")});return f.promise()}}}(),fa=function(){var d=[];return{add:function(f,e,h,l,c,a){d.push({tabId:f,name:e,uuid:h,accessKey:l,id:c,response:a})},list:function(){return d},listByTabId:function(f){var e=
{};return d.filter(function(d){var l=d.uuid+d.name;return d.tabId==f&&!e[l]&&(e[l]=!0)})},clearByTabId:function(f){d=d.filter(function(d){return d.tabId!=f})},getByTabId:function(f){return d.filter(function(d){return d.tabId==f})[0]},clearById:function(f){d=d.filter(function(d){return d.id!=f})},getById:function(f){return d.filter(function(d){return d.id==f})[0]}}}(),Ka=function(){return{create:function(){var q,m,e,h,l,c,a,b,g,k,v,t,y,r;k=null;q={name:d.getMessage("General"),sub_menu_item:!0,items:[]};
q.items.push({name:d.getMessage("Config_Mode"),id:"configMode",level:0,option:!0,select:[{name:d.getMessage("Novice"),value:0},{name:d.getMessage("Beginner"),value:50},{name:d.getMessage("Advanced"),value:100}],value:f.values.configMode,desc:d.getMessage("Changes_the_number_of_visible_config_options")});q.items.push({name:d.getMessage("Language"),id:"i18n",level:0,option:!0,reload:!0,warning:d.getMessage("A_reload_is_required"),select:[{name:"Browser Default",value:null}].concat(d.supported),value:f.values.i18n,
validation:{image:"info",opacity:.9,msg:d.getMessage("Your_language_is_not_supported__Click_here_to_get_intructions_how_to_translate_TM_"),url:"https://www.tampermonkey.net/faq.php#Q500"}});q.items.push({name:d.getMessage("Auto_reload_on_script_enabled"),level:20,id:"autoReload",option:!0,checkbox:!0,enabled:f.values.autoReload,desc:d.getMessage("Auto_reload_on_script_enabled_desc")});q.items.push({name:d.getMessage("Anonymous_statistics"),level:0,id:"statistics_enabled",option:!0,checkbox:!0,enabled:!!f.values.statistics_enabled,
validation:{image:"info",opacity:.9,msg:d.getMessage("Allow_Tampermonkey_to_collect_anonymous_statistics_via_Google_Analytics"),url:"https://www.tampermonkey.net/privacy.php#extension"}});q.items.push({name:d.getMessage("Debug_scripts"),level:100,id:"debug",option:!0,checkbox:!0,enabled:f.values.debug,desc:""});q.items.push({name:d.getMessage("Show_fixed_source"),level:100,id:"showFixedSrc",option:!0,checkbox:!0,enabled:f.values.showFixedSrc,desc:""});q.items.push({name:d.getMessage("LogLevel"),id:"logLevel",
level:0,option:!0,select:[{name:d.getMessage("Debug"),value:60},{name:d.getMessage("Warning"),value:30},{name:d.getMessage("Error"),value:0}],value:f.values.logLevel,desc:""});p.OPTIONS.NATIVE_SCRIPT_IMPORT&&(m={name:d.getMessage("Native_Script_Import"),sub_menu_item:!0,need_save:!0,items:[]},k={},f.values.native_import&&(k=!0===p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS?{image:"button_ok",msg:d.getMessage("TM_has_access_to_file_URIs")}:{image:"critical",msg:d.getMessage("Tampermonkey_needs_access_to_file_URIs__Visit_the_FAQ_"),
url:"https://www.tampermonkey.net/faq.php#Q204"}),m.items.push({name:d.getMessage("Enable_Native_Script_Import"),id:"native_import",level:0,option:!0,checkbox:!0,enabled:f.values.native_import,validation:k}),m.items.push({name:d.getMessage("Post_Import_Action"),id:"native_import_post_action",level:0,option:!0,select:[{name:d.getMessage("None"),value:"none"},{name:d.getMessage("Disable_Extension"),value:"disable"},{name:d.getMessage("Uninstall_Extension"),value:"uninstall"}],value:f.values.native_import_post_action,
desc:d.getMessage("What_action_should_be_done_after_a_native_userscript_was_imported_sucessfully_")}),k={},f.values.native_import&&(k=Q.isPathValid()?{image:"button_ok",msg:d.getMessage("Everything_is_setup_correctly_")}:{image:"critical",msg:d.getMessage("Tampermonkey_needs_to_know_the_absolute_path_to_your_browser_profile_folder_Visit_the_FAQ_"),url:"https://www.tampermonkey.net/faq.php#Q205"}),m.items.push({name:d.getMessage("Browser_Profile_Path"),id:"native_import_path",level:0,option:!0,text:!0,
width:2,value:f.values.native_import_path,validation:k}));t={name:d.getMessage("Script_Sync"),sub_menu_item:!0,level:50,need_save:!0,items:[]};t.items.push({name:d.getMessage("Enable_Script_Sync"),id:"sync_enabled",level:50,option:!0,checkbox:!0,enabled:f.values.sync_enabled,desc:d.getMessage("Synchronize_your_scripts_across_browsers_and_operation_systems")});e=function(){var a=[],c={reset_sync:!0,cloud_url:!1,cloud_user:!1,cloud_pass:!1};rea.storage.sync.supported&&a.push({name:d.getMessage("Browser_Sync"),
value:H.types.eCHROMESYNC,enable:c});a.push({name:"Google Drive",value:H.types.eGDRIVE,enable:c});p.RUNTIME.CHROME&&37>p.RUNTIME.BROWSER_VERSION||p.RUNTIME.SAFARI&&8>p.RUNTIME.BROWSER_VERSION||p.RUNTIME.DOLPHIN?n.info("Script Sync: no Dropbox support due to missing SHA-256 capabilities"):a.push({name:"Dropbox",value:H.types.eDROPBOX,enable:c});a.push({name:"WebDAV",value:H.types.eWEBDAV,enable:{reset_sync:!0,cloud_url:!0,cloud_user:!0,cloud_pass:!0}});return a}();t.items.push({name:d.getMessage("Sync_Type"),
id:"sync_type",enabler:!0,level:50,option:!0,select:e,value:f.values.sync_type});t.items.push({name:d.getMessage("URL"),id:"cloud_url",enabledBy:"sync_type",level:50,option:!0,text:!0,width:2,value:f.values.cloud_url});t.items.push({name:d.getMessage("Login"),id:"cloud_user",enabledBy:"sync_type",level:50,option:!0,text:!0,width:2,value:f.values.cloud_user});t.items.push({name:d.getMessage("Password"),id:"cloud_pass",enabledBy:"sync_type",level:50,option:!0,text:!0,password:!0,width:2,value:f.values.cloud_pass});
t.items.push({name:d.getMessage("Sync_Reset"),id:"reset_sync",enabledBy:"sync_type",level:80,button:!0,reload:!0,value:0,warning:d.getMessage("This_will_remove_all_remote_data_from_sync_Ok_")});c={name:d.getMessage("Appearance"),sub_menu_item:!0,need_save:!0,items:[],warning:d.getMessage("A_reload_is_required"),reload:!0};c.items.push({name:d.getMessage("Layout"),id:"layout",level:0,option:!0,select:ma.getLayouts(),value:f.values.layout,desc:""});c.items.push({name:d.getMessage("Custom_CSS"),id:"layout_user_css",
level:100,option:!0,input:!0,value:f.values.layout_user_css,desc:d.getMessage("You_can_add_your_custom_CSS_rules_here_")});k={};"off"==f.values.notification_showUpdate&&(k={image:"critical",msg:d.getMessage("Are_you_sure_that_you_don_t_want_to_be_notified_of_updates_")});c.items.push({name:d.getMessage("Update_Notification"),id:"notification_showUpdate",level:50,option:!0,select:[{name:d.getMessage("Disabled"),value:"off"},{name:d.getMessage("Show_notification"),value:"notification"},{name:d.getMessage("Open_changelog"),
value:"changelog"}],value:f.values.notification_showUpdate,validation:k});c.items.push({name:d.getMessage("Favicon_Service"),id:"favicon_service",level:50,option:!0,select:[{name:d.getMessage("Google"),value:"google"},{name:d.getMessage("DuckDuckGo"),value:"duckduckgo"},{name:d.getMessage("Native"),value:"native",warning:d.getMessage("Warning_unsafe_site_warnings_might_appear_")}],value:f.values.favicon_service});a={name:d.getMessage("Action_Menu"),sub_menu_item:!0,need_save:!0,items:[],level:50};
a.items.push({name:d.getMessage("Hide_disabled_scripts"),id:"action_menu_scripts_hide_disabled",level:100,option:!0,checkbox:!0,enabled:f.values.action_menu_scripts_hide_disabled,desc:""});a.items.push({name:d.getMessage("Columns"),id:"action_menu_columns",level:50,option:!0,select:[{name:d.getMessage("1"),value:"1"},{name:d.getMessage("2"),value:"2"},{name:d.getMessage("3"),value:"3"}],value:f.values.action_menu_columns});a.items.push({name:d.getMessage("Script_order"),id:"action_menu_scripts_sort",
level:50,option:!0,select:[{name:d.getMessage("Auto"),value:"auto"},{name:d.getMessage("Position_"),value:"position"},{name:d.getMessage("Name"),value:"name"},{name:d.getMessage("Enabled"),value:"enabled"}],value:f.values.action_menu_scripts_sort});a.items.push({name:d.getMessage("Icon_badge_info"),id:"appearance_badges",level:50,option:!0,select:[{name:d.getMessage("Disabled"),value:"off"},{name:d.getMessage("Running_scripts"),value:"running"},{name:d.getMessage("Unique_running_scripts"),value:"running_unique"},
{name:d.getMessage("Disabled_scripts"),value:"disabled"}],value:f.values.appearance_badges});(p.RUNTIME.CHROME||p.RUNTIME.FIREFOX)&&a.items.push({name:d.getMessage("Icon_badge_color"),id:"appearance_badge_color",level:100,color:!0,value:f.values.appearance_badge_color});e={name:d.getMessage("Editor"),sub_menu_item:!0,level:20,need_save:!0,items:[],warning:d.getMessage("A_reload_is_required"),reload:!0};e.items.push({name:d.getMessage("Enable_Editor"),id:"editor_enabled",level:100,option:!0,checkbox:!0,
enabled:f.values.editor_enabled,desc:""});e.items.push({name:d.getMessage("Theme"),id:"editor_theme",level:50,option:!0,select:ma.getEditorThemes(),value:f.values.editor_theme});e.items.push({name:d.getMessage("Font_Size"),id:"editor_fontSize",level:50,option:!0,select:[{name:"50%",value:50},{name:"70%",value:70},{name:"80%",value:80},{name:"90%",value:90},{name:"100%",value:100},{name:"110%",value:110},{name:"120%",value:120},{name:"150%",value:150}],value:f.values.editor_fontSize});e.items.push({name:d.getMessage("Key_Mapping"),
id:"editor_keyMap",level:50,option:!0,select:[{name:d.getMessage("Windows"),value:"windows"},{name:d.getMessage("Sublime"),value:"sublime"},{name:d.getMessage("Emacs"),value:"emacs"},{name:d.getMessage("Vim"),value:"vim"}],value:f.values.editor_keyMap});e.items.push({name:d.getMessage("Indentation_Width"),id:"editor_indentUnit",level:50,option:!0,select:[{name:d.getMessage("1"),value:1},{name:d.getMessage("2"),value:2},{name:d.getMessage("3"),value:3},{name:d.getMessage("4"),value:4},{name:d.getMessage("5"),
value:5},{name:d.getMessage("6"),value:6},{name:d.getMessage("7"),value:7},{name:d.getMessage("8"),value:8},{name:d.getMessage("9"),value:9},{name:d.getMessage("10"),value:10},{name:d.getMessage("11"),value:11}],value:f.values.editor_indentUnit,desc:""});e.items.push({name:d.getMessage("Indent_with"),id:"editor_indentWithTabs",level:50,option:!0,select:[{name:d.getMessage("Tabs"),value:"tabs"},{name:d.getMessage("Spaces"),value:"spaces"}],value:f.values.editor_indentWithTabs,desc:""});e.items.push({name:d.getMessage("TabMode"),
id:"editor_tabMode",level:50,option:!0,select:[{name:d.getMessage("Classic"),value:"classic"},{name:d.getMessage("Smart"),value:"smart"},{name:d.getMessage("Indent"),value:"indent"}],value:f.values.editor_tabMode,desc:""});e.items.push({name:d.getMessage("Line_break"),id:"editor_lineWrapping",level:50,option:!0,checkbox:!0,enabled:f.values.editor_lineWrapping,desc:""});e.items.push({name:d.getMessage("Reindent_on_typing"),id:"editor_electricChars",level:50,option:!0,checkbox:!0,enabled:f.values.editor_electricChars,
desc:""});e.items.push({name:d.getMessage("Enable_autoSave"),id:"editor_autoSave",level:20,option:!0,checkbox:!0,enabled:f.values.editor_autoSave,desc:""});e.items.push({name:d.getMessage("Enable_easySave"),id:"editor_easySave",level:20,option:!0,checkbox:!0,enabled:f.values.editor_easySave,desc:""});e.items.push({name:d.getMessage("Highlight_trailing_whitespace"),id:"editor_highlightTrailingWhitespace",level:50,option:!0,checkbox:!0,enabled:f.values.editor_highlightTrailingWhitespace,desc:""});e.items.push({name:d.getMessage("Trim_trailing_whitespace_from_modified_lines"),
id:"editor_trimTrailingSpacesFromModifiedLines",level:50,option:!0,checkbox:!0,enabled:f.values.editor_trimTrailingSpacesFromModifiedLines,desc:""});e.items.push({name:d.getMessage("Auto_syntax_check_on_typing"),id:"editor_autoLint",level:50,option:!0,checkbox:!0,enabled:f.values.editor_autoLint,desc:d.getMessage("Enable_this_option_to_automatically_check_the_code_on_typing_")});e.items.push({name:d.getMessage("Auto_syntax_check_max_length"),id:"editor_autoLintMaxLen",level:50,option:!0,text:!0,value:f.values.editor_autoLintMaxLen,
desc:d.getMessage("Check_only_scripts_up_to_this_size_automatically_")});e.items.push({name:d.getMessage("Custom_Linter_Config"),id:"editor_linter_config",level:100,option:!0,input:!0,json:!0,value:f.values.editor_linter_config,validation:{image:"info",opacity:.9,msg:d.getMessage("You_can_add_your_custom_linter_config_here_"),url:"https://eslint.org/docs/user-guide/configuring"}});l={name:d.getMessage("Script_Update"),sub_menu_item:!0,level:0,items:[]};l.items.push({name:d.getMessage("Check_disabled_scripts"),
id:"scriptUpdateCheckDisabled",level:0,option:!0,checkbox:!0,enabled:f.values.scriptUpdateCheckDisabled,desc:""});l.items.push({name:d.getMessage("Dont_ask_me_for_simple_script_updates"),id:"notification_silentScriptUpdate",level:80,option:!0,checkbox:!0,enabled:f.values.notification_silentScriptUpdate,desc:""});l.items.push({name:d.getMessage("Check_interval"),id:"scriptUpdateCheckPeriod",level:0,option:!0,select:[{name:d.getMessage("Never"),value:0},{name:d.getMessage("Every_6_Hours"),value:216E5},
{name:d.getMessage("Every_12_Hour"),value:432E5},{name:d.getMessage("Every_Day"),value:864E5},{name:d.getMessage("Every_Week"),value:6048E5}],value:f.values.scriptUpdateCheckPeriod,desc:""});l.items.push({name:d.getMessage("Hide_notification_after"),id:"scriptUpdateHideNotificationAfter",level:50,option:!0,select:[{name:d.getMessage("Never"),value:0},{name:d.getMessage("15_Seconds"),value:15E3},{name:d.getMessage("30_Seconds"),value:3E4},{name:d.getMessage("1_Minute"),value:6E4},{name:d.getMessage("5_Minutes"),
value:3E5},{name:d.getMessage("1_Hour"),value:36E5}],value:f.values.scriptUpdateHideNotificationAfter,desc:""});h={name:d.getMessage("Externals"),sub_menu_item:!0,level:0,items:[]};h.items.push({name:d.getMessage("Update_interval"),id:"external_update_interval",level:0,option:!0,select:[{name:d.getMessage("Always"),value:1},{name:d.getMessage("Every_Day"),value:864E5},{name:d.getMessage("Every_Week"),value:6048E5},{name:d.getMessage("Every_Month"),value:2592E6},{name:d.getMessage("Never"),value:0}],
value:f.values.external_update_interval,desc:""});b={name:d.getMessage("Security"),sub_menu_item:!0,need_save:!0,level:50,items:[]};p.OPTIONS.HAS_CSP&&(b.items.push({name:d.getMessage("Add_TM_to_CSP"),id:"webrequest_fixCSP",level:80,option:!0,select:[{name:d.getMessage("Yes"),value:"yes"},{name:d.getMessage("No"),value:"no"}],value:f.values.webrequest_fixCSP,desc:d.getMessage("Tampermonkey_might_not_be_able_to_provide_access_to_the_unsafe_context_when_this_is_disabled")}),b.items.push({name:d.getMessage("Allow_headers_to_be_modified_by_scripts"),
id:"webrequest_modHeaders",level:80,option:!0,reload:!0,select:[{name:d.getMessage("Yes"),value:"yes"},{name:d.getMessage("Auto"),value:"auto"},{name:d.getMessage("No"),value:"no"}],value:f.values.webrequest_modHeaders,warning:d.getMessage("Tampermonkey_needs_to_be_restarted_to_make_this_change_apply_Do_you_want_to_continue_"),desc:""}));p.RUNTIME.ALLOWS_FILE_SCHEME_ACCESS&&b.items.push({name:d.getMessage("Script_local_files_access"),id:"script_file_access",level:80,option:!0,select:[{name:d.getMessage("All_local_files"),
value:"all"},{name:d.getMessage("require_and_resource"),value:"externals"},{name:d.getMessage("Disabled"),value:"off"}],value:f.values.script_file_access});b.items.push({name:d.getMessage("Allow_communication_with_cooperate_pages"),id:"external_connect",level:80,option:!0,reload:!0,select:[{name:d.getMessage("Tampermonkey_and_script_version"),value:"all"},{name:d.getMessage("Tampermonkey_version"),value:"version"},{name:d.getMessage("Disabled"),value:"off"}],value:f.values.external_connect,desc:d.getMessage("This_option_allows_the_Tampermonkey_homepage_and_some_script_hosting_pages_to_determine_the_Tampermonkey_version_and_whether_a_script_is_installed_")});
b.items.push({name:d.getMessage("Subresource_Integrity"),id:"require_sri_mode",level:80,option:!0,select:[{name:d.getMessage("Disabled"),value:"ignore"},{name:d.getMessage("Validate_if_supported"),value:"supported"},{name:d.getMessage("Validate_if_given"),value:"given"},{name:d.getMessage("Enforce"),value:"enforce"}],value:f.values.require_sri_mode,desc:d.getMessage("Script_authors_can_secure_external_resources_by_adding_a_SRI_hash_to_the_URL_")});b.items.push({name:d.getMessage("connect_mode"),id:"connect_mode",
level:50,option:!0,select:(80<=f.values.configMode||-1!=["off","casual"].indexOf(f.values.connect_mode)?[{name:d.getMessage("Disabled"),value:"off"},{name:d.getMessage("Casual"),value:"casual"}]:[]).concat([{name:d.getMessage("Ask_if_unknown"),value:"ask"},{name:d.getMessage("Strict"),value:"strict"},{name:d.getMessage("Always_ask"),value:"paranoid"}]),value:f.values.connect_mode,desc:""});p.RUNTIME.INCOGNITO_MODE&&!rea.extension.inIncognitoContext&&(k="temporary"==f.values.incognito_mode?{}:{image:"critical",
msg:"Permanent mode is still a BETA feature!"},b.items.push({name:d.getMessage("Store_data_in_incognito_mode"),id:"incognito_mode",level:50,option:!0,select:[{name:d.getMessage("Temporary"),value:"temporary"},{name:d.getMessage("Permanent"),value:"permanent"}],value:f.values.incognito_mode,validation:k}));b.items.push({name:d.getMessage("Page_Filter_Mode"),id:"page_filter_mode",level:50,option:!0,select:[{name:d.getMessage("Disabled"),value:"off"},{name:d.getMessage("Blacklist"),value:"black"},{name:d.getMessage("Whitelist"),
value:"white"},{name:d.getMessage("Both"),value:"black+white"}],value:f.values.page_filter_mode,desc:""});b.items.push({name:d.getMessage("Whitelisted_Pages"),id:"page_whitelist",level:50,option:!0,input:!0,array:!0,value:f.values.page_whitelist,desc:""});b.items.push({name:d.getMessage("Blacklisted_Pages"),id:"forbiddenPages",level:50,option:!0,input:!0,array:!0,value:f.values.forbiddenPages,desc:""});g={name:d.getMessage("BlackCheck"),sub_menu_item:!0,need_save:!0,level:50,items:[]};g.items.push({name:d.getMessage("Script_Blacklist_Source"),
id:"script_blacklist_type",level:50,option:!0,select:[{name:d.getMessage("Disabled"),value:"off"},{name:d.getMessage("Server_And_Manual"),value:"server"},{name:d.getMessage("Only_Manual"),value:"only_manual"}],value:f.values.script_blacklist_type});g.items.push({name:d.getMessage("Blacklist_Severity"),id:"script_blacklist_severity",level:50,option:!0,select:[{name:d.getMessage("severity_1"),value:1},{name:d.getMessage("severity_2"),value:2},{name:d.getMessage("severity_3"),value:3},{name:d.getMessage("severity_4"),
value:4},{name:d.getMessage("severity_5"),value:5},{name:d.getMessage("severity_6"),value:6},{name:d.getMessage("severity_7"),value:7},{name:d.getMessage("severity_8"),value:8},{name:d.getMessage("severity_9"),value:9},{name:d.getMessage("severity_10"),value:G.SEVERITY_MAX}],value:f.values.script_blacklist_severity});g.items.push({name:d.getMessage("Manual_Script_Blacklist"),id:"require_blacklist",level:50,option:!0,input:!0,array:!0,value:f.values.require_blacklist,desc:""});if(p.OPTIONS.CAN_DOWNLOAD){var F=
!1;k={};w.map("exe sh crx com bat scr".split(" "),function(a){return"name."+a}).forEach(function(a){F|=K.is_whitelisted(a)});F&&(k={image:"critical",msg:d.getMessage("Your_whitelist_seems_to_include_executable_files_This_means_your_userscripts_may_download_malware_or_spyware_to_your_harddisk_")});r={name:d.getMessage("Downloads")+" BETA",sub_menu_item:!0,need_save:!0,level:50,items:[]};r.items.push({name:d.getMessage("Download_Mode"),id:"downloads_mode",level:50,option:!0,select:w.select([{name:d.getMessage("Default"),
value:K.staticVars.DEFAULT},{name:d.getMessage("Disabled"),value:K.staticVars.OFF},{name:d.getMessage("Native"),value:K.staticVars.NATIVE},{name:d.getMessage("Browser_API"),value:rea.downloads.supported?K.staticVars.CHROME:null}],function(a){return a.value}),value:f.values.downloads_mode,desc:d.getMessage("The_Browser_API_mode_requires_a_special_permission_")});r.items.push({name:d.getMessage("Whitelisted_File_Extensions"),id:"downloads_extension_whitelist",level:50,option:!0,input:!0,array:!0,value:f.values.downloads_extension_whitelist,
desc:d.getMessage("Only_files_with_these_extensions_can_be_saved_to_the_harddisk_Be_careful_to_not_allow_file_extensions_that_represent_executables_at_your_operating_system_"),validation:k})}v={name:d.getMessage("Experimental"),sub_menu_item:!0,level:80,items:[]};p.RUNTIME.FAST_EXEC_SUPPORT&&(k="fast"==f.values.runtime_inject_mode?{image:"critical",msg:"This might cause higher CPU usage!"}:{},v.items.push({name:d.getMessage("Inject_Mode"),id:"runtime_inject_mode",level:80,option:!0,select:[{name:d.getMessage("Default"),
value:"default"},{name:d.getMessage("Instant"),value:"instant"},{name:d.getMessage("Normal"),value:"normal"}],value:f.values.runtime_inject_mode,validation:k}));v.items.push({name:d.getMessage("strict_mode"),id:"runtime_strict_mode",level:80,option:!0,select:[{name:d.getMessage("Default"),value:"byscript"},{name:d.getMessage("Always"),value:"on"},{name:d.getMessage("Disabled"),value:"off"}],value:f.values.runtime_strict_mode});rea.webRequest.filterResponseData&&p.OPTIONS.HAS_CSP&&v.items.push({name:"Add Tampermonkey to the sites content CSP",
id:"webrequest_fixContentCSP",level:80,option:!0,select:[{name:d.getMessage("Yes"),value:"yes"},{name:d.getMessage("No"),value:"no"}],value:f.values.webrequest_fixContentCSP,warning:"Warning: enabling this option is may break pages!"});k={name:d.getMessage("Userscripts"),sub_menu_item:!0,need_save:!0,level:80,items:[]};k.items.push({name:d.getMessage("Script_URL_detection"),id:"scriptUrlDetection",level:80,option:!0,select:[{name:d.getMessage("Auto"),value:"auto"},{name:d.getMessage("Disabled"),value:"manual"}],
value:f.values.scriptUrlDetection});k.items.push({name:d.getMessage("New_script_template_"),id:"script_templates",level:80,option:!0,input:!0,array:!0,named:!0,value:f.values.script_templates});y={name:d.getMessage("Reset_Section"),sub_menu_item:!0,level:50,items:[]};y.items.push({name:d.getMessage("Restart_Tampermonkey"),id:"reset_simple",level:50,button:!0,reload:!0,value:0,warning:d.getMessage("This_will_restart_Tampermonkey_Ok_")});y.items.push({name:d.getMessage("Factory_Reset"),id:"reset_factory",
level:80,button:!0,reload:!0,value:0,warning:d.getMessage("This_will_remove_all_scripts_and_reset_all_settings_Ok_")});xa&&y.items.push({name:"Install Tests",id:"install_tests",level:80,button:!0,reload:!1,ignore:!0,value:0,warning:"This will install a lot of test scripts!"});return[q,c,a,l,h,void 0,t,m,void 0,e,b,g,r,k,v,y].filter(function(a){return!!a})}}}(),U=function(){return{create:function(q,u){q=q||"";u=u||{};var e=function(c){return m.onebyone(c).fail(function(){n.warn("tree: wait failed!")}).then(function(a){return a.filter(function(a){return a})})},
h=function(c,a){for(var b=c.replace(/\.$/,"").split("."),d=l;b.length;){var e=b.shift();if(d[e]){if("function"===typeof d[e])return function(){return d[e](u,!a)};d=d[e];b.length||b.unshift("root")}else return n.warn("tree: unable to find",c,u),function(){return m.Pledge([])}}n.warn("tree: unable to find",c,u);return function(){return m.Pledge([])}},l={actions:{root:function(c){var a=m();rea.tabs.getSelected(null,function(b){b&&0<=b.id?u.tab=b:c.tabId&&(u.tab={id:c.tabId,url:null});b=e([h("actions.general"),
h("actions.scripts"),h("actions.commands")]);a.consume(b)});return a.promise()},general:function(){var c=u.tab,a=c?c.url:null,b=a&&4<a.length&&""==a.substr(0,4).replace(/file|http/,"")?a:"",g=[],c={name:"enabled",sub_menu_item:!0,pos:"top",items:[],tabId:c?c.id:null};c.items.push({name:d.getMessage("Enabled"),display:f.values.enabled?null:"greyed",id:"enabled",button:!0,reload:!0,enabler:!0});c.items=c.items.concat(O.actionStatus().map(function(a){return{options:a,globalhint:!0}}));g.push(c);var e;
!ra.isScriptUrl(a,!0)||(e=ra.isScriptUrl(a))&&"manual"!=f.values.scriptUrlDetection||c.items.push({name:e?d.getMessage("Install_this_script"):d.getMessage("Try_to_install_as_script"),image:"script_download",id:"installFromUrl",data:a,button:!0,reload:!0});a={name:"about",sub_menu_item:!0,pos:"bottom",items:[]};a.items.push({name:d.getMessage("Dashboard"),image:"utilities",url:rea.extension.getURL("options.html")+"#"+["url="+J.Base64.encode(b),"nav=dashboard"].join("&"),newtab:!0});b="version="+rea.extension.manifest.version+
"&ext="+rea.runtime.short_id;a.items.push({image:"about",id:"about",urls:[{name:" "+d.getMessage("Help"),url:"https://www.tampermonkey.net/faq.php?"+b,newtab:!0},{name:" "+d.getMessage("Changelog"),url:"https://www.tampermonkey.net/changelog.php?"+b,newtab:!0}]});g.push(a);return m.Pledge(g)},scripts:{root:function(c){var a=u.tab,b=a?a.url:null,g=[],e=b?A.parse(b):null,e=e&&-1!=["http:","https:","file:"].indexOf(e.protocol)?A.woHash(e):"",h,l={name:"scripts",sub_menu_item:!0,pos:"center",items:[]},
q=Z.getContexters(!0,null),n={},p={},r={},na={};a&&[x.getUniqueScriptsForTab(a),x.getScriptHistoryForTab(a)].forEach(function(a,c){var b;Object.keys(a).forEach(function(e){var g=a[e];c?(n[e]=g.urls,p[e]=g.count,(b=r[e])||(g=z.getByUid(e),r[e]=g.script&&g.cond?b=g.script:b={uuid:e,name:d.getMessage("This_script_was_deleted"),enabled:!0,deleted:!0}),na[e]="a"+b.name.toLowerCase()+b.position):(r[e]=b=g.script,na[e]="z"+b.name.toLowerCase()+b.position)})});var Ba;Ba="position"==f.values.action_menu_scripts_sort?
function(a,c){return a.position-c.position}:"name"==f.values.action_menu_scripts_sort?function(a,c){return a.name.toLowerCase()<c.name.toLowerCase()?-1:a.name.toLowerCase()>c.name.toLowerCase()?1:0}:"enabled"==f.values.action_menu_scripts_sort?function(a,c){return 1E4*(a.enabled?0:1)+a.position-(1E4*(c.enabled?0:1)+c.position)}:function(a,c){return na[a.uuid].localeCompare(na[c.uuid])};var r=w.values(r).sort(Ba),q=wa([].concat(r).concat(q),{active_urls:n,active_counts:p}),Y=a?La(a.id):{};f.values.action_menu_scripts_hide_disabled&&
(q=q.filter(function(a){return a.enabled||p[a.uuid]}));q.forEach(function(a){var c;if(c=Y[a.uuid])a.menu_cmds=c});!f.values.action_menu_scripts_hide_disabled&&2<Math.min(f.values.action_menu_columns,(c?c.available_columns:null)||99)?(h={name:"scripts_right",sub_menu_item:!0,pos:"right",items:[]},q.forEach(function(a){(a.enabled||p[a.uuid]?l:h).items.push(a)}),g.push(l),h.items.length&&g.push(h)):(h=l,l.items=l.items.concat(q),g.push(l));f.values.enabled&&!q.length&&b&&(T.isAllowed(b)?l.items.push({name:d.getMessage("No_script_is_running"),
image:"no_script"}):l.items.push({name:d.getMessage("This_page_is_blacklisted_at_the_security_settings"),image:"critical"}));c=d.getLocale();f.values.enabled&&("3"==f.values.action_menu_columns||100>f.values.configMode||!q.length)&&(q.length?(a={name:"scripts_new",sub_menu_item:!0,pos:"center",items:[]},g.push(a)):a=l,a.items.push({name:d.getMessage("Get_new_scripts___"),image:"script_search",url:"https://www.tampermonkey.net/scripts.php"+(c?"?locale="+c:""),newtab:!0}),a.items.push({name:d.getMessage("Add_new_script___"),
image:"script_add",url:rea.extension.getURL("options.html")+"#url="+J.Base64.encode(e)+"&nav=new-user-script",newtab:!0}));return m.Pledge(g)}},commands:function(){var c=[],a=d.getLocale(),b={name:"commands",id:"commands",sub_menu_item:!0,pos:"left",items:[]};b.items.push({name:d.getMessage("Check_for_userscripts_updates"),id:"run_script_updates",button:!0,image:"update"});80<=f.values.configMode&&b.items.push({name:d.getMessage("Report_a_bug"),image:"bug",url:"https://www.tampermonkey.net/bug",newtab:!0});
b.items.push({name:d.getMessage("Please_consider_a_contribution"),image:"contrib",url:"https://www.tampermonkey.net/contrib.php?src=a"+(a?"&locale="+a:""),newtab:!0});c.push(b);return m.Pledge(c)}},options:{root:function(){return e([h("options.general"),h("options.verification"),h("options.scripts"),h("options.settings")])},general:function(){var c,a=[];a.push({name:"Version",id:null,version:!0,value:rea.extension.manifest.version});rea.extension.inIncognitoContext&&"temporary"==f.values.incognito_mode?
a.push({globalhint:!0,options:{image:"critical",text:d.getMessage("All_modifications_are_only_kept_until_this_incognito_session_is_closed_")}}):(c=O.optionsStatus().map(function(a){return{options:a,globalhint:!0}}))&&c.length?a=a.concat(c):(c=ha.updateAvailable())&&a.push({globalhint:!0,options:{image:"info",class:"information",text:d.getMessage("0name0_0version0_is_available__Please_re_start_your_browser_to_update_",rea.extension.manifest.name,c)}});return m.Pledge(a)},verification:function(){var c=
[];ka.getWarnings().forEach(function(a){c.push({globalhint:!0,options:{image:"critical",class:"warning",text:a.text,title:a.description,info_url:a.url}})});return m.Pledge(c)},scripts:{root:function(c,a){var b=m(),g={name:d.getMessage("Installed_userscripts"),main_menu_item:!0,scriptTab:!0,id:"dashboard"};(function(){if(c.complete||!a)return e(w.map(["options.scripts.natives","options.scripts.userscripts","options.scripts.new"],function(a){return h(a)}));g.referrer="options.scripts";g.partial=!0;
return e([h("options.scripts.new")])})().done(function(a){g.items=a;b.resolve([g])}).fail(b.reject);return b.promise()},"new":function(){var c=[];c.push({name:d.getMessage("New_userscript"),id:null,image:"script_add",icon:rea.extension.getURL("images/txt.png"),nnew:!0,uuid:"new-user-script",position:-1,positionof:p.RUNTIME.MAX_SCRIPTS,enabled:!0,userscript:!0});return m.Pledge(c)},natives:function(){var c=[],a=m();Q.getAllUserscripts().always(function(b){b=b||[];b.forEach(function(a){c.push({name:a.name,
uuid:a.id,icon:a.icon,code:null,position:0,positionof:p.RUNTIME.MAX_SCRIPTS,enabled:a.enabled,version:a.version,description:a.description,nativeScript:!0})});a.resolve(c)});return a.promise()},userscripts:{root:function(c,a){var b=c.complete||!a?null:"options.scripts.userscripts",b=wa(x.determineScriptsToRun(null),{options_page:!0,referrer:b}),e=b.length,f=d.getLocale();b.push({name:d.getMessage("No_script_is_installed"),image:"info",visible:!e});b.push({name:d.getMessage("Get_some_scripts___"),image:"edit_add",
url:"https://www.tampermonkey.net/scripts.php"+(f?"?locale="+f:""),newtab:!0,visible:!e});return m.Pledge(b)},matches:function(c){if(!c.uuid)return m.Pledge([]);var a=z.getByUid(c.uuid),b;return a.script&&a.cond&&(b=c.filter)?(c=/\/(.*)\/(.*)/.exec(b.code),m.Pledge([-1!=a.script.textContent.search(new RegExp(c[1],c[2]))])):m.Pledge([])},source:function(c){if(!c.uuid)return m.Pledge([]);c=z.getByUid(c.uuid);if(c.script&&c.cond)return c=f.values.showFixedSrc?ta.mkCompat(c.script.textContent,c.script,
"off"!=f.values.runtime_strict_mode):c.script.textContent,m.Pledge([c]);n.warn("tree: unable to process ",c);return m.Breach()},storage:function(c){return c.uuid?m.Pledge([z.getStorageByUid(c.uuid).data]):m.Pledge([])},external:function(c){if(!c.uuid)return m.Pledge([]);var a=z.getByUid(c.uuid);if(a.script&&a.cond){var b;[].concat(a.script.requires).concat(a.script.resources).some(function(a){a=a.url||A.sanitize(a.unsafe_url,a.abs_url);if(a==c.url&&(a=P.getElement(c.uuid,a))&&a.data&&a.data.content)return b=
a.data.content,!0});return m.Pledge([b])}n.warn("tree: unable to process ",a);return m.Breach()}}},settings:function(c,a){var b=m(),e={name:d.getMessage("Settings"),main_menu_item:!0,id:"settings",selected_default:!0},f;c.complete||!a?f=m.Pledge(Ka.create()):(e.referrer="options.settings",f=m.Pledge());f.done(function(a){e.items=a;b.resolve([e])}).fail(b.reject);return b.promise()}}};n.debug("tree: loading",q,u);return h(q,!0)()}}}(),La=function(d){var f={};d=null==d||void 0==d?fa.list():fa.listByTabId(d);
for(var e in d)if(d.hasOwnProperty(e)){var h=d[e];(f[h.uuid]=f[h.uuid]||[]).push({name:h.name,uuid:h.uuid,id:h.id,accessKey:h.accessKey,image:"menu_cmd",menucmd:!0})}return f},wa=function(q,m){var e=[];m=m||{};var h=new C.Script;["author","copyright"].forEach(function(d){h[d]=!1});Object.keys(q).forEach(function(l){var c=q[l],a;if(m.options_page){a={};var b=["textContent","requires","resources"];Object.keys(h).forEach(function(d){-1==b.indexOf(d)&&(w.toType(h[d]),a[d]=c[d])});m.referrer?(a.referrer=
m.referrer,a.length=c.textContent.length):a.code=c.textContent;["requires","resources"].forEach(function(b){a[b]=w.map(c[b],function(a){var d=a.url||A.sanitize(a.unsafe_url,a.abs_url),e=P.getElement(c.uuid,d),f=0,h=null,l=null,q,n,p,r;e&&e.data&&(e.data.content&&(r=e.data.content,f=r.length),l=e.data.sri,h=e.ts,q=e.modified,p=e.data.meta||"text/plain",n="requires"==b||/text\/.*|application\/(?:x-)?(?:java|ecma)script/.test(p));return{display_url:a.url||a.unsafe_url,abs_url:a.abs_url,unsafe_url:a.unsafe_url,
url:d,data:{length:f,content:m.externals?r:void 0},sri:l,ts:h,mimetype:p,editable:n,modified:q}})});a.origin=x.determineOrigin(c);a.contexter=x.isContexter(c);a.temp_connects=ja.getSessionConnects(c.uuid);l=z.getStorageByUid(c.uuid);a.storage_key_count=Object.keys(l.data).length;a.remote_url=N.getSyncRemoteUrl(c);a.lastUpdated=c.lastUpdated}else l=x.determineOrigin(c),a={name:c.name,name_i18n:c.name_i18n,uuid:c.uuid,system:c.system,support:!!c.supportURL||l&&!!l.issue_url,abuse:l&&!!l.abuse_url,active_urls:(m.active_urls||
{})[c.uuid],active_count:(m.active_counts||{})[c.uuid],referrer:m.referrer,contexter:x.isContexter(c),enabled:c.enabled,position:c.position,deleted:c.deleted};c.evilness&&(c.evilness==G.SEVERITY_FOISTED_SCRIPT?a.blacklisted=d.getMessage("The_origin_of_this_script_cant_be_determined_"):c.evilness>=Math.min(G.SEVERITY_MAX,f.values.script_blacklist_severity)&&(a.blacklisted=d.getMessage("This_script_is_blacklisted_")));c.evilness&&(a.warnings=G.getWarningsFor(x.determineSourceURL(c)));a.file_url=c.downloadURL||
c.fileURL;a.positionof=q.length;a.userscript=!0;c.icon64||c.icon||(a.icon64=rea.extension.getURL("images/txt.png"));c.options&&Object.keys(h.options).forEach(function(b){a[b]=c.options[b]});e.push(a)});return e},V={run:function(d,f){var e=1,h=function(){0==--e&&(f&&f(),rea.page.reload())};if("config"==d){var l=r.listValues();Object.keys(l).forEach(function(c){c=l[c];-1==c.search(p.CONSTANTS.PREFIX.SCRIPT)&&-1==c.search(p.CONSTANTS.PREFIX.COND)&&-1==c.search(p.CONSTANTS.PREFIX.STORE)&&-1==c.search(p.CONSTANTS.PREFIX.META)&&
(e++,r.deleteValue(c).always(h))})}else"factory"==d&&(e++,K.remove_permission().done(h),e++,r.factoryReset().always(h));h()},reset:function(d){V.run(null,d)},factoryReset:function(d){V.run("factory",d)},configReset:function(d){V.run("config",d)}},R=function(){var m=function(){rea.runtime.lastError&&void 0},p={init:function(){p.setIcon();var d=f.values.appearance_badge_color||"#ee3131";"#"!==d[0]&&(d="#"+d);rea.browserAction.setBadgeBackgroundColor({color:d})},setIcon:function(e){var h,l;l=null;var c=
h=!1;void 0===e||E.get.empty(e)||(h=E.get.blocker(e),c=E.get.forbidden(e));c?(h="_forbidden",l=d.getMessage("At_least_one_part_of_this_page_is_listed_at_the_forbidden_pages_setting_")):h?(h="_blocker",l=d.getMessage("Some_scripts_might_be_blocked_by_the_javascript_settings_for_this_page_or_a_script_blocker_")):h=f.values.enabled&&void 0!==e?"":"_grey";n.debug("badge: set icon "+h);h={path:rea.extension.getURL("images/icon"+h+".png")};l={title:l?l:rea.extension.manifest.name};null!=e&&(h.tabId=e,l.tabId=
e);try{rea.browserAction.setIcon(h,m),rea.browserAction.setTitle(l)}catch(a){n.warn("bg: ERROR while setIcon! "+a.message)}},setBadge:function(d){var h=0;"off"==f.values.appearance_badges?h=0:"running"==f.values.appearance_badges?d&&!E.get.empty(d)&&(h=E.get.stats(d).running):"running_unique"==f.values.appearance_badges?d&&!E.get.empty(d)&&(h=E.get.stats(d,!0).unique):"disabled"==f.values.appearance_badges&&d&&!E.get.empty(d)&&(h=E.get.stats(d).disabled);n.debug("badge: set "+h);h?rea.browserAction.setBadgeText({text:h.toString(),
tabId:d}):rea.browserAction.setBadgeText({text:"",tabId:d})}};return p}(),ea=function(){var d=null,f={init:function(){d=r.getValue(p.CONSTANTS.STORAGE.BEGGING,null);var e,h=Date.now();d?(e=r.getValue(p.CONSTANTS.STORAGE.LAST_START,0))&&12096E5<h-e&&(d.later={type:"after_pause",ts:h},f.save()):(d={first_run:{type:"from_init",ts:h}},f.save())},save:function(){r.setValue(p.CONSTANTS.STORAGE.BEGGING,d)},needed:function(){var e=Date.now(),f=d.first_run?d.first_run.ts+12096E5<e:!0,l=!d.hide,c=!d.contributed,
e=d.later?d.later.ts+12096E5<e:!0;if(!p.RUNTIME.DOLPHIN&&f&&l&&c&&e)return d.later?"l":"i"},clicked:function(d,f,l){L.tG("clicked",d,f+l)},dialog:{shown:function(e){var h=Date.now();d.dialog={ts:h,extra:e};f.save();L.tG("dialog")}},button:function(){var e={};["contributed","later","hide"].forEach(function(h){e[h]=function(e,c){var a=Date.now();d[h]={ts:a,type:e,extra:c};f.save();L.tG("button",h)}});return e}()};return f}(),pa=function(){var d=function(a,c){n.debug(a,c);if(c&&a.menuItemId){var b=z.getByUid(a.menuItemId);
b&&b.script?Ea.bundle({url:a.frameUrl||a.pageUrl||"<unknown>"},b.script,!0).then(function(b){var d=m();b.method="executeScript";a.frameUrl?b.url=A.woHash(a.frameUrl):b.topframe=!0;rea.tabs.sendMessage(c.id,b,d.resolve);return d.promise()}):n.debug("ctxm: unable to find script "+a.menuItemId,a,c)}},f=[],e=null,h=!1,l=function(a){var c=[];w.each(a,function(a){var b=m();rea.contextMenus.create({id:a.uuid,contexts:["all"],parentId:e,title:a.name,type:"normal",documentUrlPatterns:["http://*/*","https://*/*",
"file://*/*"]},function(){b.resolve()});f.push(a.uuid);c.push(b.promise())});return m.when(c)},c=function(){var a=m();rea.contextMenus.removeAll(function(){e=null;a.resolve()});return a.promise()},a=function(){var a=m();c().then(function(){e=rea.contextMenus.create({contexts:["all"],title:"Tampermonkey",type:"normal",documentUrlPatterns:["http://*/*","https://*/*","file://*/*"]},function(){a.resolve()})});return a.promise()},b=function(){var b=Z.getContexters(!0,null);if(b.length){var d;d=e?m.Pledge():
a();return d.then(function(){return l(b)})}return c().then(g.clean)},g={init:function(){rea.contextMenus.supported&&(g.clean().then(b).then(function(){h=!0}),rea.contextMenus.onClicked.addListener(d))},clean:function(){var a=m();f.forEach(function(a){rea.contextMenus.remove(a)});f=[];a.resolve();return a.promise()},onScriptsChanged:function(){if(rea.contextMenus.supported&&h)return g.clean().then(b)},getContexterCount:function(){return f.length}};return g}(),ia=function(){var d={},m={},e=("TM_"+w.createUUID().substr(0,
5)).toLowerCase(),h=["x-webkit-csp","x-content-security-policy","content-security-policy"],l=rea.webRequest.extraHeaderNeeded,c=function(a,c){var b,d,e,f,g,h=a.split(";");h.forEach(function(a,c){0===a.search(/^\s*script-src /)?d=c:0===a.search(/^\s*default-src /)?e=c:0===a.search(/^\s*img-src /)&&(f=c)});var k,l;void 0!==e&&void 0===d&&(b=!0,h.push(h[e].replace(/default-src /,"script-src ")),d=h.length-1);void 0!==e&&void 0===f&&(b=!0,h.push(h[e].replace(/default-src /,"img-src ")),f=h.length-1);
void 0!==f&&(l=!1,k=h[f],-1==k.search(/'data:'/)&&(l=!0,k=k.replace(/img-src /,"img-src data: ")),-1!=k.search(/'none'/)&&(l=!0,k=k.replace(/ 'none'/,"")),l&&(h[f]=k,b=!0));void 0!==d&&(l=!1,k=h[d],-1==k.search(/'unsafe-eval'/)&&(l=!0,k=k.replace(/script-src /,"script-src 'unsafe-eval' ")),-1!=k.search(/'none'/)&&(l=!0,k=k.replace(/ 'none'/,"")),p.RUNTIME.FIREFOX&&(-1==k.search(/'unsafe-inline'/)&&(l=g=!0,k=k.replace(/script-src /,"script-src 'unsafe-inline' ")),-1==k.search(/'strict-dynamic'/)&&
-1!=k.search(/ '(nonce|sha[0-9]+)-[^\']+'/)&&(l=!0,k=k.replace(/ '(nonce|sha[0-9]+)-[^\']+'/g," *"))),l&&(h[d]=k,b=!0));void 0!==e&&(l=!1,k=h[e],g&&-1!=k.search(/ 'self'/)&&(l=!0,h[e]=k.replace(/default-src /,"default-src blob: data: ")),l&&(b=!0));return b?h.join(";"):null},a=function(a,c){var b,d,e=a.split(";");e.forEach(function(a,c){0===a.search(/^\s*sync-xhr /)&&(d=c)});var f,g;void 0!==d&&(g=!1,f=e[d],-1!=f.search(/'none'/)&&(g=!0,f=f.replace(/ 'none'/," *")),g&&(e[d]=f,b=!0));return b?e.join(";"):
null},b=function(a,c){var b,d=a.url;Object.keys(c).forEach(function(a){var e=c[a];w.each(e.rules,function(a,c){var f,g;if((f=a.selector)&&(g=a.action)){var h,k=e.id+"/"+c;(h=M.items.regexp.get(k))||(h=x.regexify({inc:f.include,match:f.match,exc:f.exclude}),M.items.regexp.set(k,h));if(x.validUrl(d,h)){g.cancel&&(n.debug("webRequest: request was canceled by script "+e.uuid,d,a,e),e.callback&&e.callback({type:"cancel",details:{rule:a,url:d}}),b={cancel:!0});if(g.redirect){var l,m,p,q;g.redirect.url?
l=g.redirect.url:(m=g.redirect.from)&&(p=g.redirect.to)&&(q=d.match(m,p))&&(q.shift(),l=p,q.concat(["","",""]).forEach(function(a,c){l=l.replace("$"+(c+1),a||"")}));f=function(c){n.warn("webRequest: error while request redirect by script "+e.uuid,d,a,e);e.callback&&e.callback({type:"redirect",message:"error",details:{description:c,rule:a,url:d,redirect_url:l}})};if(!l){f("unable to determine the redirect URL");return}l=A.woHash(l);T.isAllowed(l)?x.scriptWillRun(e.uuid,l)?(n.debug("webRequest: request was redirected by script "+
e.uuid,d,l,a,e),e.callback&&e.callback({type:"redirect",details:{rule:a,url:d,redirect_url:l}}),b={redirectUrl:l}):f("the redirect URL needs to be included by the scripts @include or @match tag"):f("the redirect URL is filtered by the security settings")}if(b)return!1}}})});return b},g=function(a){var c=[],b=a.requestHeaders||[],d,f,g={},h=new RegExp("^"+e),b=b.filter(function(b){if(b.name&&0==b.name.search(h))f=b.name.replace(h,""),g[f.toLowerCase()]=!0,"internal"==f?m[a.requestId]=b.value:b.value&&
c.push({name:f,value:J.decodeS(b.value)}),d=!0;else return!0});if(d)return{requestHeaders:b.filter(function(a){return!a.name||!g[a.name.toLowerCase()]}).concat(c)}},k=function(a){if(I.late)if("main_frame"==a.type){if(E.events.reset(a.tabId,!0),0<a.tabId&&"POST"!=a.method&&"auto"==f.values.scriptUrlDetection&&ra.isScriptUrl(a.url))return x.installFromUrl(a.url,{},{silent_fail:!0}).fail(function(c){n.info("webRequest: user script detected @ "+a.url+" was invalid",c?c.messages:"");rea.tabs.update(a.tabId,
{url:a.url+"#bypass=true"},function(){})}).done(function(){p.RUNTIME.EDGE&&rea.tabs.query({windowType:"normal"},function(c){c.forEach(function(c){c.id===a.tabId&&rea.tabs.update(c.id,{url:c.url},function(){})})})}),p.RUNTIME.EDGE?{cancel:!0}:{redirectUrl:"javascript:history.back()"}}else{var c,d;if((c=E.get.requests(a.tabId,a.frameId))&&(d=b(a,c)))return d}else I.registerLateCallback(function(){k(a)})},r=function(b,e){if(I.late){var g=b.responseHeaders||[];if("xmlhttprequest"==b.type){var k,l;if(m[b.requestId]){p.XMLHTTPREQUEST.COOKIE_PASSTHROUGH||
g.forEach(function(a){a.name&&a.value&&-1!=a.name.toLowerCase().indexOf("set-cookie")&&(g.push({name:"tm-setcookie"+rea.runtime.short_id.toLowerCase(),value:a.value}),l=!0)});if(k=d[b.requestId])g.push({name:"tm-finalurl"+rea.runtime.short_id.toLowerCase(),value:k}),l=!0;if(l)return{responseHeaders:g}}}else{var n,t,y,w,x=p.OPTIONS.HAS_CSP&&"yes"==f.values.webrequest_fixCSP,D=x&&p.RUNTIME.CHROME&&60<=p.RUNTIME.BROWSER_VERSION;g.some(function(a){if(a.name)return a=a.name.toLowerCase(),t|="location"==
a,x&&(y|=-1!=h.indexOf(a)),D&&(w|="feature-policy"==a),t});if(!t){(k=E.events.response(b.tabId,b.frameId,b.url))&&(y||w)&&g.forEach(function(d,e){if(d.name&&d.value){var f=d.name.toLowerCase();if(-1!=h.indexOf(f)){var k;if(k=c(d.value,b))n=!0,g[e]={name:d.name,value:k}}"feature-policy"==f&&(f=a(d.value,b))&&(n=!0,g[e]={name:d.name,value:f})}});var z;if(p.RUNTIME.FAST_EXEC_SUPPORT&&-1!=["instant"].indexOf(f.values.runtime_inject_mode)&&(z=E.events.run(b.tabId,b.frameId,null,b.url))){var C=A.parse(b.url),
C=C.pathname+C.search,C="TM_"+rea.runtime.short_id+J.Base64.encode(C.length+C).substr(0,255).replace(/[#=\/]/g,"_")+Date.now();z=Z.answer(z,b.url);z=JSON.stringify(z);z=new Blob([z],{type:"binary/octet-stream"});z=URL.createObjectURL(z);E.set.objurl(b.tabId,b.frameId,z);g.push({name:"set-cookie",value:C+"="+window.encodeURIComponent(z)+"; max-age=15;"});n=!0}if(k&&!e&&rea.webRequest.filterResponseData&&p.OPTIONS.HAS_CSP&&"yes"==f.values.webrequest_fixCSP&&"yes"==f.values.webrequest_fixContentCSP&&
-1!=["main_frame","sub_frame"].indexOf(b.type)){var H;g.some(function(a){if(a.name&&a.value&&"content-type"==a.name.toLowerCase()&&"text/html"==a.value.split(";")[0].toLowerCase().trim())return H=!0});if(H){var G=rea.webRequest.filterResponseData(b.requestId);G.ondata=function(a){var d=(new TextDecoder("x-user-defined")).decode(a.data,{stream:!0}),e=new RegExp('(<head>[\\s\\S]*)(<meta[^>]+http-equiv="(?:'+h.join("|")+')"[^>]*>)([\\s\\S]*?<\\/head>)',"i"),f,d=d.replace(e,function(a,d,e,g){return d+
e.replace(/(content=")([^">]+)(")/,function(a,d,e,g){if(a=c(e||"",b))f=!0;return d+(a||e)+g})+g});f?G.write(J.str2arrbuf(d)):G.write(a.data);G.disconnect();G=null};G.onstop=function(){G&&G.disconnect()}}}if(n)return p.RUNTIME.FIREFOX&&(g=g.filter(function(a){return"cache-control"!=a.name.toLowerCase()}),g.push({name:"cache-control",value:"no-cache, no-store, must-revalidate"})),{responseHeaders:g}}}}else I.registerLateCallback(function(){r(b,!0)})},t=function(a){d[a.requestId]=a.redirectUrl},y=function(a){I.late?
"xmlhttprequest"==a.type?(delete m[a.requestId],delete d[a.requestId]):a.fromCache&&E.events.response(a.tabId,a.frameId,a.url):I.registerLateCallback(function(){y(a)})},D=function(a){"xmlhttprequest"==a.type?(delete m[a.requestId],delete d[a.requestId]):E.events.reset(a.tabId,!0)};return{getPrefix:function(){return e},init:function(a){try{var b;b=p.RUNTIME.EDGE?["http://*/*","https://*/*"]:["http://*/*","https://*/*","ftp://*/*","file:///*"].concat(p.RUNTIME.WEBREQUEST_WEBSOCKET?["ws://*/*","wss://*/*"]:
[]);a?(rea.webRequest.onBeforeRequest.addListener(k,{urls:b,types:["main_frame","sub_frame","script","xmlhttprequest"].concat(p.RUNTIME.WEBREQUEST_WEBSOCKET?["websocket"]:[])},["blocking"]),rea.webRequest.onHeadersReceived.addListener(r,{urls:b,types:["main_frame","sub_frame","xmlhttprequest"]},["blocking","responseHeaders"].concat(l?["extraHeaders"]:[])),p.RUNTIME.WEBREQUEST_XHR_SUPPORT&&rea.webRequest.onBeforeRedirect.addListener(t,{urls:b,types:["xmlhttprequest"]},[]),rea.webRequest.onResponseStarted.addListener(y,
{urls:b,types:["main_frame","sub_frame","xmlhttprequest"]},[]),rea.webRequest.onErrorOccurred.addListener(D,{urls:b,types:["main_frame","xmlhttprequest"]})):p.RUNTIME.WEBREQUEST_XHR_SUPPORT&&"no"!=f.values.webrequest_modHeaders&&rea.webRequest.onBeforeSendHeaders.addListener(g,{urls:b,types:["xmlhttprequest"]},["blocking","requestHeaders"].concat(l?["extraHeaders"]:[]));rea.webRequest.handlerBehaviorChanged()}catch(c){n.warn("webRequest: error initializings",c.message)}},scripts:{set:function(a,b,
c,d,e){var f=[];d.forEach(function(a){var b="string"===typeof a.selector?{include:[a.selector]}:a.selector;["include","match","exclude"].forEach(function(b){"string"===typeof a.selector[b]&&(a.selector[b]=[a.selector[b]])});var c=a.action;if("string"===typeof c){var d=c,c={};c[d]=!0}"string"===typeof a.action.redirect&&(a.action.redirect={url:a.action.redirect});f.push({selector:b,action:c})});E.set.requests(a,b,c,{id:c+"@"+a+":"+b+"#"+Date.now(),rules:f,uuid:c,callback:e})}}}}(),I={late:!1,callbacks:[],
init:function(){},registerLateCallback:function(d){n.debug("toea: register callback");I.callbacks.push(d)},ensureLate:function(d){I.late?d():I.registerLateCallback(d)},setReady:function(){n.debug("toea: run "+I.callbacks.length+" callbacks");I.late=!0;for(var d=0;d<I.callbacks.length;d++)I.callbacks[d]();I.callbacks=[]}},Ma=function(){var d=!1,f=null,e=function(){d||(n.debug("Unloader.onbeforeunload()"),f&&f(),d=!0)};return{init:function(d){f=d;window.addEventListener("beforeunload",e,!1)}}}(),ha=
function(){var q=null,u=rea.extension.manifest.version,e=null,h=!1,l=!1,c=function(){if(I.late){var a="version="+u+"&ext="+rea.runtime.short_id+"&updated=true",b;h?(b="https://www.tampermonkey.net/installed.php?"+a,l=!0):(a+="&old="+e,b="https://www.tampermonkey.net/changelog.php?"+a);"off"!=f.values.notification_showUpdate&&("notification"==f.values.notification_showUpdate?S.showUpdate(d.getMessage("Updated_to__0version0",u),d.getMessage("Click_here_to_see_the_recent_changes"),rea.extension.getURL("images/icon128.png"),
function(a){a.clicked&&rea.tabs.create({url:b},function(){})}):"changelog"==f.values.notification_showUpdate&&(l||(b+="&intr=true"),l=!0,rea.tabs.create({url:b,active:l},function(){})))}else I.registerLateCallback(c)},a=function(){var a=null,b,c=m(),d=function(){b&&(b=null,c.resolve(!!a))};b=window.setTimeout(d,300);rea.idle.queryState(p.MISC.IDLE_TIMEOUT,function(b){a="active"==b;d()});return c.promise()},b=function(){var a=m(),b=function(){var b=Date.now(),c=r.getValue(p.CONSTANTS.STORAGE.LAST_START,
0),b=Math.round((b-c)/1E3),c=b<=p.MISC.DISTURBANCE_ALLOWED;n.debug("upd: restart?",c,"(",b,"seconds ago)");a.resolve(c)};I.late?b():I.registerLateCallback(b);return a.promise()}(),g=function(){var d=!1,e=!1;a().then(function(a){e=a;return b}).then(function(a){d=a}).always(function(){l=!e||d;c();v=!0})},k=null,v=!1,t={scheduleNotification:function(a,b){v||(e=a,h|=b,k&&window.clearTimeout(k),k=window.setTimeout(g,1E3))},updateAvailable:function(){return q},onInstalled:function(){t.scheduleNotification(null,
!0)},onUpdated:function(a){t.scheduleNotification(a,!1)},onUpdateAvailable:function(a){n.info("An update to version",a.version,"is available");q=a.version;window.setTimeout(function(){S.show(d.getMessage("Update"),d.getMessage("0name0_0version0_is_available__Please_re_start_your_browser_to_update_",rea.extension.manifest.name,a.version),rea.extension.getURL("images/icon128.png"),6E4)},864E5)}};(function(){I.registerLateCallback(function(){r.setValue(p.CONSTANTS.STORAGE.LAST_START,Date.now())})})();
return t}(),Na=function(d){(function(){var n=m();"toggle-enable"==d?(f.values.enabled=!f.values.enabled,n.resolve()):rea.tabs.getSelected(null,function(e){var f;"open-dashboard"==d?f=rea.extension.getURL("options.html")+"#nav=dashboard":"open-dashboard-with-running-scripts"==d?f=rea.extension.getURL("options.html")+"#nav=dashboard&filter="+encodeURIComponent(e.url):"open-new-script"==d&&(f=rea.extension.getURL("options.html")+"#url="+J.Base64.encode(e.url)+"&nav=new-user-script");n.resolve(f?{url:f,
active:!0,parent:e}:null)});return n.promise()})().then(function(d){d&&rea.tabs.create(d)})},ya=function(){var d=[],m=function(a,b,c){I.late?("auto"==f.values.scriptUrlDetection&&ra.isScriptUrl(c.url)&&x.installFromUrl(c.url,{},{silent_fail:!0}),c.url?"loading"==b.status?E.events.loading(c.id,0,c.url):"complete"==b.status&&E.events.complete(c.id,0,c.url):n.warn("tabUpdates: no tab url set! ",c),d.forEach(function(a){a({reason:"updated",status:b.status},c)})):window.setTimeout(function(){m(a,b,c)},
100)},e=function(a,b){ga[a]&&(ga[a].onClose(),delete ga[a]);E.events.remove(a);d.forEach(function(b){b({reason:"removed"},{id:a})})},h=function(a,b){e(b,{});R.setIcon(a);R.setBadge(a);d.forEach(function(b){b({reason:"replaced"},a)})},l=function(a){I.late?(E.events.commited(a.tabId,a.frameId,a.url),0===a.frameId&&d.forEach(function(b){b({reason:"commited"},{url:a.url,id:a.tabId})})):window.setTimeout(function(){l(a)},100)},c={init:function(){rea.tabs.onUpdated.addListener(m);rea.tabs.onRemoved.addListener(e);
rea.tabs.onReplaced.addListener(h);rea.webNavigation.supported&&rea.webNavigation.onCommitted.addListener(l)},openAndWatch:function(a,b){var d=null,e=function(a,f){null!==d&&f.id===d&&(-1!=["updated","commited"].indexOf(a.reason)?b(f):"removed"==a.reason&&(c.removeListener(e),b()))};rea.tabs.create(a,function(a){d=a.id;b(a)});c.addListener(e);return{cancel:function(){c.removeListener(e);null!==d&&(rea.tabs.remove(d,function(){}),d=null)}}},addListener:function(a){d.push(a)},removeListener:function(a){var b;
d&&-1<(b=d.indexOf(a))&&d.splice(b,1)}};return c}(),Fa=function(){var d="temporary"==f.values.incognito_mode&&rea.extension.inIncognitoContext;r.setTemporary(d);d&&(f.values.native_import=!1,f.values.sync_enabled=!1,f.values.scriptUpdateCheckPeriod=0,f.values.sync_type=0,f.values.statistics_enabled=!1)},Oa=function(){n.set(f.values.logLevel);d.setLocale(f.values.i18n);Q.setPath(f.values.native_import_path);var m=p.RUNTIME.WEBREQUEST_XHR_SUPPORT&&"no"!=f.values.webrequest_modHeaders;W=Registry.get("xmlhttprequest");
W.setConfig({prefix:m?ia.getPrefix():null,mozAnon:p.RUNTIME.FIREFOX});ba.init();L.init("bg",rea.extension.manifest.version);L.setEnabled(f.values.statistics_enabled);E.listeners.add.onReset(function(d,e){fa.clearByTabId(d);z.removeStorageListeners({tabid:d},!1);e||R.setIcon(d)});m=function(d){rea.tabs.get(d,function(e){!rea.runtime.lastError&&e&&(R.setIcon(d),R.setBadge(d))})};E.listeners.add.onCommited(m);E.listeners.add.onCompleted(m);E.listeners.add.onCompleted(ja.purgeAppeals);E.listeners.add.onRemoved(ja.purgeAppeals);
E.listeners.add.onRemoved(qa.cleanTab);N.init().done(function(d){d&&N.sync()});T.init();G.init();z.init();m=function(){K.set_mode(f.values.downloads_mode);K.set_whitelist(f.values.downloads_extension_whitelist)};m();K.config_changed_listener=m;va.init();ia.init();pa.init();ea.init();ca.init()},W,ta,C,H,xa;init=function(){I.init();ia.init(!0);ya.init();Ca.init();rea.commands.supported&&rea.commands.onCommand.addListener(Na);Ma.init(function(){N.finalize()});ta=Registry.get("compat",p);C=Registry.get("parser");
H=Registry.get("syncinfo",ya);xa=Registry.get("test");rea.browserAction.setIcon({path:rea.extension.getURL("images/icon_grey.png")});rea.browserAction.setPopup({popup:"action.html"});rea.browserAction.setTitle({title:"Tampermonkey"});rea.runtime.onUpdateAvailable.addListener(ha.onUpdateAvailable);rea.runtime.onInstalled.addListener(function(d){n.debug("bg: onInstalled",d);d||(d={reason:"mandatory_argument_is_not_set"});if("install"==d.reason)da.onInstalled();else if("update"==d.reason)da.onUpdated(d.previousVersion);
I.ensureLate(function(){if("chrome_update"==d.reason)L.tB({updated:!0});else if("install"==d.reason)ha.onInstalled();else if("update"==d.reason)ha.onUpdated(d.previousVersion)})});r.init().then(Ga).then(da.init).then(f.init).then(function(){cfgo=f;Fa();Oa();Ja();R.init();window.setTimeout(ca.check,1E4);da.check().then(function(){n.debug("Listeners registered!");window.setTimeout(I.setReady,1)})})};init()}});
