From e86b12af50d23f1e1a0124f6c200c1de2c65aba9 Mon Sep 17 00:00:00 2001 From: nobody Date: Sun, 7 Jun 2020 07:49:51 +0200 Subject: [PATCH] Added Cloudflare Mirage2 (#22) --- core/files.js | 3 +++ core/mappings.js | 3 ++- core/resources.js | 5 +++++ pages/updates/updates.html | 1 + resources/mirage2/latest/mirage2.min.jsm | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 resources/mirage2/latest/mirage2.min.jsm diff --git a/core/files.js b/core/files.js index 37a7f8b9..a1f826c1 100644 --- a/core/files.js +++ b/core/files.js @@ -272,6 +272,9 @@ var files = { 'resources/mdbootstrap/4.18.0/js/mdb.min.jsm': true, 'resources/mdbootstrap/4.18.0/css/mdb.min.css': true, + // Cloudflare Mirage 2 + 'resources/mirage2/latest/mirage2.min.jsm': true, + // Modernizr 'resources/modernizr/2.8.3/modernizr.min.jsm': true, diff --git a/core/mappings.js b/core/mappings.js index 1cfb2c7e..81bd9939 100644 --- a/core/mappings.js +++ b/core/mappings.js @@ -665,7 +665,8 @@ var mappings = { // Cloudflare Rocket-Loader 'ajax.cloudflare.com': { '/': { - 'cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.': resources.cfRocketLoader + 'cdn-cgi/scripts/7089c43e/cloudflare-static/rocket-loader.min.': resources.cfRocketLoader, + 'cdn-cgi/scripts/04b3eb47/cloudflare-static/mirage2.': resources.mirage2 } }, // Akamai WebCDN diff --git a/core/resources.js b/core/resources.js index fbba0277..dd6dea51 100644 --- a/core/resources.js +++ b/core/resources.js @@ -354,6 +354,11 @@ var resources = { 'path': 'resources/mdbootstrap/{version}/css/mdb.min.css', 'type': 'text/css' }, + // Cloudflare Mirage 2 + 'mirage2': { + 'path': 'resources/mirage2/latest/mirage2.min.jsm', + 'type': 'application/javascript' + }, // Modernizr 'modernizr': { 'path': 'resources/modernizr/{version}/modernizr.min.jsm', diff --git a/pages/updates/updates.html b/pages/updates/updates.html index 71ca1a59..beb21875 100644 --- a/pages/updates/updates.html +++ b/pages/updates/updates.html @@ -26,6 +26,7 @@
  • Fixed: Norwegian language package in Chromium (#21)
  • Added: Algoliasearch to cdnjs.cloudflare.com (#22)
  • Added: Swiper JS+CSS v4.5.1 and v5.4.2 (#22)
  • +
  • Added: Cloudflare Mirage2 (#22)
  • Please update your uBlock/uMatrix rules diff --git a/resources/mirage2/latest/mirage2.min.jsm b/resources/mirage2/latest/mirage2.min.jsm new file mode 100644 index 00000000..229f3ff1 --- /dev/null +++ b/resources/mirage2/latest/mirage2.min.jsm @@ -0,0 +1 @@ +var mirage=function(t){"use strict";function e(){throw new Error("Dynamic requires are not currently supported by rollup-plugin-commonjs")}function r(t){return Object.prototype.toString.call(t)}function n(t){return[].slice.call(t)}function i(){return(new Date).getTime()}function o(t){return null!=t&&"object"==typeof t&&t.nodeType===Node.ELEMENT_NODE&&"object"==typeof t.style&&"object"==typeof t.ownerDocument}function s(t,e){for(var r=0;r=2e3&&e<=50?"slow-2g":t>=1400&&e<=70?"2g":t>=270&&e<=700?"3g":"4g"}function x(t,e,r){var n,i,o,s,a=t.byteLength;if(e=~~e,r=void 0===r?a:~~r,"function"==typeof t.slice)return t.slice(e,r);if(e<0?(e+=a)<0&&(e=0):e>a&&(e=a),r<0?(r+=a)<0&&(r=0):r>a&&(r=a),rx',t.firstChild.href}}(),_t=(Object.freeze||Object)({parseURL:pt,sameOrigin:dt,resolveFullURL:gt});S.prototype.add=function(t){var e;return this.tokens?(this.tokens.add(t),this):(e=this.array(),s(e,t)<0&&e.push(t),this.element.className=e.join(" "),this)},S.prototype.remove=function(t){var e,r;return this.tokens?(this.tokens.remove(t),this):(e=this.array(),(r=s(e,t))>=0?(e.splice(r,1),this.element.className=e.join(" "),this):void 0)},S.prototype.toggle=function(t){return this.tokens?(this.tokens.toggle(t),this):(this.has(t)?this.remove(t):this.add(t),this)},S.prototype.array=function(){var t,e;return t=this.element.className.replace(/^\s+|\s+$/g,""),""===(e=t.split(/\s+/))[0]&&e.shift(),e};var mt=T;S.prototype.has=S.prototype.contains=function(t){return this.tokens?this.tokens.contains(t):!!~s(this.array(),t)};var yt=(Object.freeze||Object)({add:function(t,e){return new S(t).add(e)},remove:E,toggle:function(t,e){new S(t).toggle(e)},has:T,contains:mt,Classes:S}),vt={};vt.log=function(t,e){var r={};r.message=t,r.category=e,vt.history.push(r)};var wt=function(t,e,r){if(it){try{console.log("[ CLOUDFLARE ] "+t)}catch(t){}!1!==r&&vt.log(t,1|e)}},bt=function(t,e,r){if(it){try{console.error("[ CLOUDFLARE ] "+t)}catch(r){wt(t,4|e,!1)}!1!==r&&vt.log(t,4|e)}},St={bandwidth:1/0},Et="mirage_network_connection",Tt="X-Mirage-Server-Time",Ot="X-Mirage-Transfer-Size",At="/cdn-cgi/mirage_speedtest/",It=1.25,Lt=(Object.freeze||Object)({isHighLatency:O,getFakeConnection:A,connectionFromStats:L,calculateEffectiveConnectionType:C}),Ct={};for(var xt in ht)Ct[xt]=ht[xt];var Nt=window.URL||window.webkitURL||window.mozURL,Pt=function(){var t;return window.location.origin?window.location.origin:(t=pt(window.location.toString())).protocol+"://"+t.host+":"+t.port}();return j.DEFAULT_TTL=1728e5,j.STORAGE_KEY="mirage_cache_manifest",j.DEBOUNCE_THRESHOLD=500,j.MAX_LENGTH=100,j.prototype.record=function(t){return this.whenReady_(function(){this.add_(t),this.persist_()})},j.prototype.has=function(t){return this.whenReady_(function(){return this.has_(t)})},j.prototype.indexOf=function(t){return this.whenReady_(function(){return this.indexOf_(this.map_[t])})},j.prototype.clear=function(){return this.whenReady_(function(){try{window.localStorage.removeItem(j.STORAGE_KEY)}catch(t){}this.reset_()})},j.prototype.whenReady_=function(t){return this.queue_=this.queue_.then(R(t,this)),this.queue_},j.prototype.has_=function(t){var e=this.map_[t],r=i();return e&&e+j.DEFAULT_TTLe.value?-1:t.valuet?this.indexOf_(t,i,r):i))},j.prototype.add_=function(t){var e,r=this.sizeMap_[t];r?(e=this.indexOf_(r.value),this.sizeQueue_.splice(e,1)):(r={key:t},this.sizeMap_[t]=r),this.map_[t]=r.value=i()+this.offset_++,this.sizeQueue_.unshift(r),this.sizeQueue_.length>j.MAX_LENGTH&&this.remove_(this.sizeQueue_[this.sizeQueue_.length-1].key)},j.prototype.remove_=function(t){var e=this.sizeMap_[t],r=this.indexOf_(e.value);delete this.map_[t],delete this.sizeMap_[t],-1!==r&&this.sizeQueue_.splice(r,1)},j.prototype.persist_=function(){return this.whenReady_(function(){try{window.localStorage.setItem(j.STORAGE_KEY,JSON.stringify(this.map_))}catch(t){}})},j.prototype.persist_=function(t,e){var r=null;return function(){var n=arguments,i=this;null!==r&&window.clearTimeout(r),r=window.setTimeout(function(){t.apply(i,n)},e)}}(j.prototype.persist_,j.DEBOUNCE_THRESHOLD),M.type={SIGNATURE:[137,80,78,71,13,10,26,10],IHDR:[73,72,68,82],IEND:[73,69,78,68]},M.FIELD_BYTE_LENGTH=12,M.prototype.initializeAsSignature_=function(t,e){this.byteLength=8,this.type_=new Uint8Array(t,e,this.byteLength)},M.prototype.initializeAsChunk_=function(t,e){for(var r=new Uint8Array(t,e,4),n=0,i=0;i<4;i++)n<<=8,n|=r[i];this.byteLength=n+M.FIELD_BYTE_LENGTH,this.type_=new Uint8Array(t,e+4,4)},M.prototype.isSignature=function(){return 8===this.byteLength},M.prototype.isHeader=function(){return this.matches(M.type.IHDR)},M.prototype.isEnd=function(){return this.matches(M.type.IEND)},M.prototype.matches=function(t){for(var e=0;ee.height?r.top-e.height:0,Math.abs(t)2032),t+(r299)return u.reject()}catch(t){}if(n.readyState>2&&void 0!==n.responseText){for(var t=n.responseText;t&&c299)return s.reject()}catch(t){}if(n.readyState>2){for(var t=n.response;t&&u=1&&(this.requireProxy_=this.accessorTest(t[0])),this.capture(),this.requireProxy_&&this.captureNativeMethods(),this.isHighLatency_().then(R(function(t){return t||this.forcePreload_?this.preload():this.backfill()},this))},this))},F.prototype.postProcess_=function(t,e,r){return new G(function(n){var i=document.createElement("canvas"),o=document.createElement("img"),s=i.getContext("2d");i.width=e,i.height=r,o.addEventListener("load",R(function(){s.drawImage(o,0,0,e,r),n(i.toDataURL())},this)),o.addEventListener("error",R(function(t){bt("Error loading image."),n("")},this)),o.src=t})},F.prototype.limitPreloadableImages_=function(t){var e=[],r=[];return y(b(t,function(t){return!!t}),function(t,n){var i=dt(t);nCt.maxexternalimages&&(r.splice(e.pop(),1),r.push(t))}),G.resolve(r)},F.prototype.reducePreloadableImages_=function(){var t=[];return y(this.getUniqueSrcs_(),function(e,r){t.push(G.resolve().then(R(function(){return this.manifest_.has(e).then(function(t){if(!t)return e})},this),function(){}))},this),G.all(t).then(R(function(t){return this.limitPreloadableImages_(t).then(R(function(t){var e,r={};y(t,function(t){r[t]=!0},{});var n=[];return e=b(this.imageCache_,function(t){var e=r[t.getSrc()];return e||this.push(t),e},n),n.length>0&&window.setTimeout(function(){y(n,function(t){t.restore()})},F.RESTORE_NON_DEGRADED_IMAGE_TIMEOUT),e},this))},this))},F.prototype.getUniqueSrcs_=function(){var t={},e=[],r=[],n=window.innerWidth,i=window.innerHeight;return y(this.imageCache_,function(o){var s=o.getTop(),a=o.getLeft(),u=o.getSrc();s