You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
!function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(s,n,function(t){return e[t]}.bind(null,n));return s},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browser=r(2)},function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{l(s.next(e))}catch(e){o(e)}}function a(e){try{l(s.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}l((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.saveImages=t.contentIdToTitle=t.idAndTitlePath=t.urlToExt=void 0;const o=n(r(10)),i=r(0),a=r(14),l=r(15),g=r(3),m=r(6),c=r(5);t.urlToExt=e=>{var t,r;const s=null!==(t=e.match(/^(?:[^:/?#]+:)?(?://[^/?#])?(?:([^?#]/)([^/?#]))?(?[^#])?(?:#.)?$/))&&void 0!==t?t:[],[,,n]=s.map(e=>null!=e?e:""),o=null!==(r=n.match(/^(.+?)(.[^.]+)?$/))&&void 0!==r?r:[],[,,i]=o.map(e=>null!=e?e:"");return i};t.idAndTitlePath=(e,t)=>""!==t?(0,o.default)(${e}_${t}):(0,o.default)(${e});t.contentIdToTitle=(e,t)=>{if("post_contents"in e){const r=e.post_contents.filter(e=>e.id===t)[0];return null==r.title?"":${r.title}}if("backnumber_contents"in e){const r=e.backnumber_contents.filter(e=>e.id===t)[0];return null==r.title?"":${r.title}}return""};t.saveImages=e=>s(void 0,void 0,void 0,(function(){const r=e.target.attributes.getNamedItem("content-id");if(!r)return;const s=r.value,n=/.+/backnumbers./.test(location.href)?yield(0,a.fetchBacknumberData)():yield(0,c.fetchPostData)(),i="post_contents"in n?${(0,t.idAndTitlePath)(n.fanclub.id,n.fanclub.fanclub_name_with_creator_name)}/${(0,t.idAndTitlePath)(n.id,n.title)}/${(0,t.idAndTitlePath)(s,(0,t.contentIdToTitle)(n,Number(s)))}:${(0,t.idAndTitlePath)(n.fanclub.id,n.fanclub.fanclub_name_with_creator_name)}/${((e,t)=>{const r=e.backnumber_contents.filter(e=>e.id===t)[0];return(0,o.default)(${r.parent_post.url.split("/").pop()}_${r.parent_post.title})})(n,Number(s))}/${(0,t.idAndTitlePath)(s,(0,t.contentIdToTitle)(n,Number(s)))},l=(0,m.getPhotoContents)(n,Number(s)),u=(0,m.getImgList)(l);for(let e=0;e<u.length;e++){const r=u[e].url,s=u[e].name+(0,t.urlToExt)(r);(0,g.fileDownload)(r,i,s)}}));(()=>{const e=document.getElementById("page");if(!e)return;const t=new MutationObserver(e=>{var r;for(const s of e)if(s.target.className.includes("content-block")){const e=document.getElementsByClassName("post-btns");e.length>0&&(0,l.injectPageAllContentsDlBtn)(e[0]);const s=document.getElementsByClassName("content-block type-photo-gallery ng-scope");for(let e=0;e<s.length;e++){const t=s[e],n=null===(r=t.closest(".post-content-inner"))||void 0===r?void 0:r.id;if(n){const e=n.split("post-content-id-")[1];(0,l.injectGalleryAllDlBtn)(t,e)}}t.disconnect();break}});t.observe(e,{characterData:!1,childList:!0,subtree:!0})})(),i.browser.runtime.onMessage.addListener((e,t)=>s(void 0,void 0,void 0,(function(){"download_everything_from_a_post"===e.text&&(yield(0,c.downloadEverythingFromPost)())})))},function(e,t,r){var s,n,o;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,n=[e],void 0===(o="function"==typeof(s=function(e){"use strict";if("undefined"==typeof browser||Object.getPrototypeOf(browser)!==Object.prototype){const t="The message port closed before a response was received.",r="Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)",s=e=>{const s={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(s).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class n extends WeakMap{constructor(e,t){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,r)=>(...s)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):r.singleCallbackArg||s.length<=1&&!1!==r.singleCallbackArg?t.resolve(s[0]):t.resolve(s)},i=e=>1==e?"argument":"arguments",a=(e,t,r)=>new Proxy(t,{apply:(t,s,n)=>r.call(s,e,...n)});let l=Function.call.bind(Object.prototype.hasOwnProperty);const g=(e,t={},r={})=>{let s=Object.create(null),n={has:(t,r)=>r in e||r in s,get(n,m,c){if(m in s)return s[m];if(!(m in e))return;let u=e[m];if("function"==typeof u)if("function"==typeof t[m])u=a(e,e[m],t[m]);else if(l(r,m)){let t=((e,t)=>function(r,...s){if(s.length<t.minArgs)throw new Error(Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${s.length});if(s.length>t.maxArgs)throw new Error(Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${s.length});return new Promise((n,i)=>{if(t.fallbackToNoCallback)try{re}catch(o){console.warn(${e} API method doesn't seem to support the callback parameter, +"falling back to call it without a callback: ",o),re,t.fallbackToNoCallback=!1,t.noCallback=!0,n()}else t.noCallback?(re,n()):re})})(m,r[m]);u=a(e,e[m],t)}else u=u.bind(e);else if("object"==typeof u&&null!==u&&(l(t,m)||l(r,m)))u=g(u,t[m],r[m]);else{if(!l(r,""))return Object.defineProperty(s,m,{configurable:!0,enumerable:!0,get:()=>e[m],set(t){e[m]=t}}),u;u=g(u,t[m],r[""])}return s[m]=u,u},set:(t,r,n,o)=>(r in s?s[r]=n:e[r]=n,!0),defineProperty:(e,t,r)=>Reflect.defineProperty(s,t,r),deleteProperty:(e,t)=>Reflect.deleteProperty(s,t)},m=Object.create(e);return new Proxy(m,n)},m=e=>({addListener(t,r,...s){t.addListener(e.get(r),...s)},hasListener:(t,r)=>t.hasListener(e.get(r)),removeListener(t,r){t.removeListener(e.get(r))}}),c=new n(e=>"function"!=typeof e?e:function(t){const r=g(t,{},{getContent:{minArgs:0,maxArgs:0}});e(r)});let u=!1;const d=new n(e=>"function"!=typeof e?e:function(t,s,n){let o,i,a=!1,l=new Promise(e=>{o=function(t){u||(console.warn(r,(new Error).stack),u=!0),a=!0,e(t)}});try{i=e(t,s,o)}catch(e){i=Promise.reject(e)}const g=!0!==i&&(m=i)&&"object"==typeof m&&"function"==typeof m.then;var m;if(!0!==i&&!g&&!a)return!1;const c=e=>{e.then(e=>{n(e)},e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",n({mozWebExtensionPolyfillReject:!0,message:t})}).catch(e=>{console.error("Failed to send onMessage rejected reply",e)})};return c(g?i:l),!0}),f=({reject:r,resolve:s},n)=>{e.runtime.lastError?e.runtime.lastError.message===t?s():r(new Error(e.runtime.lastError.message)):n&&n.mozWebExtensionPolyfillReject?r(new Error(n.message)):s(n)},A=(e,t,r,...s)=>{if(s.length<t.minArgs)throw new Error(Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${s.length});if(s.length>t.maxArgs)throw new Error(Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${s.length});return new Promise((e,t)=>{const n=f.bind(null,{resolve:e,reject:t});s.push(n),r.sendMessage(...s)})},p={devtools:{network:{onRequestFinished:m(c)}},runtime:{onMessage:m(d),onMessageExternal:m(d),sendMessage:A.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:A.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return s.privacy={network:{"":h},services:{"":h},websites:{"":h}},g(e,p,s)};if("object"!=typeof chrome||!chrome||!chrome.runtime||!chrome.runtime.id)throw new Error("This script should only be loaded in a browser extension.");e.exports=s(chrome)}else e.exports=browser})?s.apply(t,n):s)||(e.exports=o)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileDownload=void 0;const s=r(0);t.fileDownload=(e,t,r)=>{const n={msg:"download",url:e,filepath:t.replaceAll("",""),filename:r};s.browser.runtime.sendMessage(n)}},function(e,t,r){"use strict";r.r(t),r.d(t,"HTTPError",(function(){return s})),r.d(t,"TimeoutError",(function(){return n}));class s extends Error{constructor(e,t,r){const s=${e.status||0===e.status?e.status:""} ${e.statusText||""}.trim();super(Request failed with ${s?status code ${s}:"an unknown error"}),this.name="HTTPError",this.response=e,this.request=t,this.options=r}}class n extends Error{constructor(e){super("Request timed out"),this.name="TimeoutError",this.request=e}}const o=e=>null!==e&&"object"==typeof e,i=(...e)=>{for(const t of e)if((!o(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("The options argument must be an object");return l({},...e)},a=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[e,t]of n.entries())s&&"undefined"===t||void 0===t?r.delete(e):r.set(e,t);return r},l=(...e)=>{let t={},r={};for(const s of e)if(Array.isArray(s))Array.isArray(t)||(t=[]),t=[...t,...s];else if(o(s)){for(let[e,r]of Object.entries(s))o(r)&&e in t&&(r=l(t[e],r)),t={...t,[e]:r};o(s.headers)&&(r=a(r,s.headers),t.headers=r)}return t},g="function"==typeof globalThis.AbortController,m="function"==typeof globalThis.ReadableStream,c="function"==typeof globalThis.FormData,u=["get","post","put","patch","head","delete"],d={json:"application/json",text:"text/",formData:"multipart/form-data",arrayBuffer:"/",blob:"/"},f=Symbol("stop"),A=e=>u.includes(e)?e.toUpperCase():e,p=[413,429,503],h={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:p,maxRetryAfter:Number.POSITIVE_INFINITY},x=(e={})=>{if("number"==typeof e)return{...h,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...h,...e,afterStatusCodes:p}};class b{constructor(e,t={}){var r,s,n;if(this._retryCount=0,this._input=e,this._options={credentials:this._input.credentials||"same-origin",...t,headers:a(this._input.headers,t.headers),hooks:l({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},t.hooks),method:A(null!==(r=t.method)&&void 0!==r?r:this._input.method),prefixUrl:String(t.prefixUrl||""),retry:x(t.retry),throwHttpErrors:!1!==t.throwHttpErrors,timeout:void 0===t.timeout?1e4:t.timeout,fetch:null!==(s=t.fetch)&&void 0!==s?s:globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("input must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("input must not begin with a slash when using prefixUrl");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(g&&(this.abortController=new globalThis.AbortController,this._options.signal&&this._options.signal.addEventListener("abort",()=>{this.abortController.abort()}),this._options.signal=this.abortController.signal),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const e="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^?/,""):new URLSearchParams(this._options.searchParams).toString()),t=this.request.url.replace(/(?:?.?)?(?=#|$)/,e);!(c&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(t,this.request),this._options)}void 0!==this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",null!==(n=this._options.headers.get("content-type"))&&void 0!==n?n:"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}static create(e,t){const r=new b(e,t),n=async()=>{if(r._options.timeout>2147483647)throw new RangeError("The timeout option cannot be greater than 2147483647");await Promise.resolve();let e=await r._fetch();for(const t of r._options.hooks.afterResponse){const s=await t(r.request,r._options,r._decorateResponse(e.clone()));s instanceof globalThis.Response&&(e=s)}if(r._decorateResponse(e),!e.ok&&r._options.throwHttpErrors){let t=new s(e,r.request,r._options);for(const e of r._options.hooks.beforeError)t=await e(t);throw t}if(r._options.onDownloadProgress){if("function"!=typeof r._options.onDownloadProgress)throw new TypeError("The onDownloadProgress option must be a function");if(!m)throw new Error("Streams are not supported in your environment. ReadableStream is missing.");return r._stream(e.clone(),r._options.onDownloadProgress)}return e},o=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[e,s]of Object.entries(d))o[e]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||s);const n=(await o).clone();if("json"===e){if(204===n.status)return"";if(t.parseJson)return t.parseJson(await n.text())}return ne};return o}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(e instanceof n)){if(e instanceof s){if(!this._options.retry.statusCodes.includes(e.response.status))return 0;const t=e.response.headers.get("Retry-After");if(t&&this._options.retry.afterStatusCodes.includes(e.response.status)){let e=Number(t);return Number.isNaN(e)?e=Date.parse(t)-Date.now():e=1e3,void 0!==this._options.retry.maxRetryAfter&&e>this._options.retry.maxRetryAfter?0:e}if(413===e.response.status)return 0}return.3*2**(this._retryCount-1)*1e3}return 0}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(t){const r=Math.min(this._calculateRetryDelay(t),2147483647);if(0!==r&&this._retryCount>0){await(async e=>new Promise(t=>{setTimeout(t,e)}))(r);for(const e of this._options.hooks.beforeRetry){if(await e({request:this.request,options:this._options,error:t,retryCount:this._retryCount})===f)return}return this._retry(e)}throw t}}async _fetch(){for(const e of this._options.hooks.beforeRequest){const t=await e(this.request,this._options);if(t instanceof Request){this.request=t;break}if(t instanceof Response)return t}return!1===this._options.timeout?this._options.fetch(this.request.clone()):(async(e,t,r)=>new Promise((s,o)=>{const i=setTimeout(()=>{t&&t.abort(),o(new n(e))},r.timeout);r.fetch(e).then(s).catch(o).then(()=>{clearTimeout(i)})}))(this.request.clone(),this.abortController,this._options)}_stream(e,t){const r=Number(e.headers.get("content-length"))||0;let s=0;return new globalThis.Response(new globalThis.ReadableStream({async start(n){const o=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array),await async function e(){const{done:i,value:a}=await o.read();if(i)n.close();else{if(t){s+=a.byteLength,t({percent:0===r?0:s/r,transferredBytes:s,totalBytes:r},a)}n.enqueue(a),await e()}}()}}))}}
The text was updated successfully, but these errors were encountered:
ここ数日いくつかのページでページ内一括保存が動かないことがあります。
コンテキスト
https://fantia.jp/posts/1739781
https://fantia.jp/posts/1742507
https://fantia.jp/posts/1741964
スタック トレース
content/index.js:1 (無名関数)
!function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(s,n,function(t){return e[t]}.bind(null,n));return s},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=1)}([function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.browser=r(2)},function(e,t,r){"use strict";var s=this&&this.__awaiter||function(e,t,r,s){return new(r||(r=Promise))((function(n,o){function i(e){try{l(s.next(e))}catch(e){o(e)}}function a(e){try{l(s.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,a)}l((s=s.apply(e,t||[])).next())}))},n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.saveImages=t.contentIdToTitle=t.idAndTitlePath=t.urlToExt=void 0;const o=n(r(10)),i=r(0),a=r(14),l=r(15),g=r(3),m=r(6),c=r(5);t.urlToExt=e=>{var t,r;const s=null!==(t=e.match(/^(?:[^:/?#]+:)?(?://[^/?#])?(?:([^?#]/)([^/?#]))?(?[^#])?(?:#.)?$/))&&void 0!==t?t:[],[,,n]=s.map(e=>null!=e?e:""),o=null!==(r=n.match(/^(.+?)(.[^.]+)?$/))&&void 0!==r?r:[],[,,i]=o.map(e=>null!=e?e:"");return i};t.idAndTitlePath=(e,t)=>""!==t?(0,o.default)(
${e}_${t}
):(0,o.default)(${e}
);t.contentIdToTitle=(e,t)=>{if("post_contents"in e){const r=e.post_contents.filter(e=>e.id===t)[0];return null==r.title?"":${r.title}
}if("backnumber_contents"in e){const r=e.backnumber_contents.filter(e=>e.id===t)[0];return null==r.title?"":${r.title}
}return""};t.saveImages=e=>s(void 0,void 0,void 0,(function(){const r=e.target.attributes.getNamedItem("content-id");if(!r)return;const s=r.value,n=/.+/backnumbers./.test(location.href)?yield(0,a.fetchBacknumberData)():yield(0,c.fetchPostData)(),i="post_contents"in n?${(0,t.idAndTitlePath)(n.fanclub.id,n.fanclub.fanclub_name_with_creator_name)}/${(0,t.idAndTitlePath)(n.id,n.title)}/${(0,t.idAndTitlePath)(s,(0,t.contentIdToTitle)(n,Number(s)))}
:${(0,t.idAndTitlePath)(n.fanclub.id,n.fanclub.fanclub_name_with_creator_name)}/${((e,t)=>{const r=e.backnumber_contents.filter(e=>e.id===t)[0];return(0,o.default)(
${r.parent_post.url.split("/").pop()}_${r.parent_post.title})})(n,Number(s))}/${(0,t.idAndTitlePath)(s,(0,t.contentIdToTitle)(n,Number(s)))}
,l=(0,m.getPhotoContents)(n,Number(s)),u=(0,m.getImgList)(l);for(let e=0;e<u.length;e++){const r=u[e].url,s=u[e].name+(0,t.urlToExt)(r);(0,g.fileDownload)(r,i,s)}}));(()=>{const e=document.getElementById("page");if(!e)return;const t=new MutationObserver(e=>{var r;for(const s of e)if(s.target.className.includes("content-block")){const e=document.getElementsByClassName("post-btns");e.length>0&&(0,l.injectPageAllContentsDlBtn)(e[0]);const s=document.getElementsByClassName("content-block type-photo-gallery ng-scope");for(let e=0;e<s.length;e++){const t=s[e],n=null===(r=t.closest(".post-content-inner"))||void 0===r?void 0:r.id;if(n){const e=n.split("post-content-id-")[1];(0,l.injectGalleryAllDlBtn)(t,e)}}t.disconnect();break}});t.observe(e,{characterData:!1,childList:!0,subtree:!0})})(),i.browser.runtime.onMessage.addListener((e,t)=>s(void 0,void 0,void 0,(function(){"download_everything_from_a_post"===e.text&&(yield(0,c.downloadEverythingFromPost)())})))},function(e,t,r){var s,n,o;"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self&&self,n=[e],void 0===(o="function"==typeof(s=function(e){"use strict";if("undefined"==typeof browser||Object.getPrototypeOf(browser)!==Object.prototype){const t="The message port closed before a response was received.",r="Returning a Promise is the preferred way to send a reply from an onMessage/onMessageExternal listener, as the sendResponse will be removed from the specs (See https://developer.mozilla.org/docs/Mozilla/Add-ons/WebExtensions/API/runtime/onMessage)",s=e=>{const s={alarms:{clear:{minArgs:0,maxArgs:1},clearAll:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getAll:{minArgs:0,maxArgs:0}},bookmarks:{create:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},getChildren:{minArgs:1,maxArgs:1},getRecent:{minArgs:1,maxArgs:1},getSubTree:{minArgs:1,maxArgs:1},getTree:{minArgs:0,maxArgs:0},move:{minArgs:2,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeTree:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}},browserAction:{disable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},enable:{minArgs:0,maxArgs:1,fallbackToNoCallback:!0},getBadgeBackgroundColor:{minArgs:1,maxArgs:1},getBadgeText:{minArgs:1,maxArgs:1},getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},openPopup:{minArgs:0,maxArgs:0},setBadgeBackgroundColor:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setBadgeText:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},browsingData:{remove:{minArgs:2,maxArgs:2},removeCache:{minArgs:1,maxArgs:1},removeCookies:{minArgs:1,maxArgs:1},removeDownloads:{minArgs:1,maxArgs:1},removeFormData:{minArgs:1,maxArgs:1},removeHistory:{minArgs:1,maxArgs:1},removeLocalStorage:{minArgs:1,maxArgs:1},removePasswords:{minArgs:1,maxArgs:1},removePluginData:{minArgs:1,maxArgs:1},settings:{minArgs:0,maxArgs:0}},commands:{getAll:{minArgs:0,maxArgs:0}},contextMenus:{remove:{minArgs:1,maxArgs:1},removeAll:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},cookies:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:1,maxArgs:1},getAllCookieStores:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},devtools:{inspectedWindow:{eval:{minArgs:1,maxArgs:2,singleCallbackArg:!1}},panels:{create:{minArgs:3,maxArgs:3,singleCallbackArg:!0},elements:{createSidebarPane:{minArgs:1,maxArgs:1}}}},downloads:{cancel:{minArgs:1,maxArgs:1},download:{minArgs:1,maxArgs:1},erase:{minArgs:1,maxArgs:1},getFileIcon:{minArgs:1,maxArgs:2},open:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},pause:{minArgs:1,maxArgs:1},removeFile:{minArgs:1,maxArgs:1},resume:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},extension:{isAllowedFileSchemeAccess:{minArgs:0,maxArgs:0},isAllowedIncognitoAccess:{minArgs:0,maxArgs:0}},history:{addUrl:{minArgs:1,maxArgs:1},deleteAll:{minArgs:0,maxArgs:0},deleteRange:{minArgs:1,maxArgs:1},deleteUrl:{minArgs:1,maxArgs:1},getVisits:{minArgs:1,maxArgs:1},search:{minArgs:1,maxArgs:1}},i18n:{detectLanguage:{minArgs:1,maxArgs:1},getAcceptLanguages:{minArgs:0,maxArgs:0}},identity:{launchWebAuthFlow:{minArgs:1,maxArgs:1}},idle:{queryState:{minArgs:1,maxArgs:1}},management:{get:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},getSelf:{minArgs:0,maxArgs:0},setEnabled:{minArgs:2,maxArgs:2},uninstallSelf:{minArgs:0,maxArgs:1}},notifications:{clear:{minArgs:1,maxArgs:1},create:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:0},getPermissionLevel:{minArgs:0,maxArgs:0},update:{minArgs:2,maxArgs:2}},pageAction:{getPopup:{minArgs:1,maxArgs:1},getTitle:{minArgs:1,maxArgs:1},hide:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setIcon:{minArgs:1,maxArgs:1},setPopup:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},setTitle:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0},show:{minArgs:1,maxArgs:1,fallbackToNoCallback:!0}},permissions:{contains:{minArgs:1,maxArgs:1},getAll:{minArgs:0,maxArgs:0},remove:{minArgs:1,maxArgs:1},request:{minArgs:1,maxArgs:1}},runtime:{getBackgroundPage:{minArgs:0,maxArgs:0},getPlatformInfo:{minArgs:0,maxArgs:0},openOptionsPage:{minArgs:0,maxArgs:0},requestUpdateCheck:{minArgs:0,maxArgs:0},sendMessage:{minArgs:1,maxArgs:3},sendNativeMessage:{minArgs:2,maxArgs:2},setUninstallURL:{minArgs:1,maxArgs:1}},sessions:{getDevices:{minArgs:0,maxArgs:1},getRecentlyClosed:{minArgs:0,maxArgs:1},restore:{minArgs:0,maxArgs:1}},storage:{local:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}},managed:{get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1}},sync:{clear:{minArgs:0,maxArgs:0},get:{minArgs:0,maxArgs:1},getBytesInUse:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}}},tabs:{captureVisibleTab:{minArgs:0,maxArgs:2},create:{minArgs:1,maxArgs:1},detectLanguage:{minArgs:0,maxArgs:1},discard:{minArgs:0,maxArgs:1},duplicate:{minArgs:1,maxArgs:1},executeScript:{minArgs:1,maxArgs:2},get:{minArgs:1,maxArgs:1},getCurrent:{minArgs:0,maxArgs:0},getZoom:{minArgs:0,maxArgs:1},getZoomSettings:{minArgs:0,maxArgs:1},goBack:{minArgs:0,maxArgs:1},goForward:{minArgs:0,maxArgs:1},highlight:{minArgs:1,maxArgs:1},insertCSS:{minArgs:1,maxArgs:2},move:{minArgs:2,maxArgs:2},query:{minArgs:1,maxArgs:1},reload:{minArgs:0,maxArgs:2},remove:{minArgs:1,maxArgs:1},removeCSS:{minArgs:1,maxArgs:2},sendMessage:{minArgs:2,maxArgs:3},setZoom:{minArgs:1,maxArgs:2},setZoomSettings:{minArgs:1,maxArgs:2},update:{minArgs:1,maxArgs:2}},topSites:{get:{minArgs:0,maxArgs:0}},webNavigation:{getAllFrames:{minArgs:1,maxArgs:1},getFrame:{minArgs:1,maxArgs:1}},webRequest:{handlerBehaviorChanged:{minArgs:0,maxArgs:0}},windows:{create:{minArgs:0,maxArgs:1},get:{minArgs:1,maxArgs:2},getAll:{minArgs:0,maxArgs:1},getCurrent:{minArgs:0,maxArgs:1},getLastFocused:{minArgs:0,maxArgs:1},remove:{minArgs:1,maxArgs:1},update:{minArgs:2,maxArgs:2}}};if(0===Object.keys(s).length)throw new Error("api-metadata.json has not been included in browser-polyfill");class n extends WeakMap{constructor(e,t){super(t),this.createItem=e}get(e){return this.has(e)||this.set(e,this.createItem(e)),super.get(e)}}const o=(t,r)=>(...s)=>{e.runtime.lastError?t.reject(new Error(e.runtime.lastError.message)):r.singleCallbackArg||s.length<=1&&!1!==r.singleCallbackArg?t.resolve(s[0]):t.resolve(s)},i=e=>1==e?"argument":"arguments",a=(e,t,r)=>new Proxy(t,{apply:(t,s,n)=>r.call(s,e,...n)});let l=Function.call.bind(Object.prototype.hasOwnProperty);const g=(e,t={},r={})=>{let s=Object.create(null),n={has:(t,r)=>r in e||r in s,get(n,m,c){if(m in s)return s[m];if(!(m in e))return;let u=e[m];if("function"==typeof u)if("function"==typeof t[m])u=a(e,e[m],t[m]);else if(l(r,m)){let t=((e,t)=>function(r,...s){if(s.length<t.minArgs)throw new Error(Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${s.length}
);if(s.length>t.maxArgs)throw new Error(Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${s.length}
);return new Promise((n,i)=>{if(t.fallbackToNoCallback)try{re}catch(o){console.warn(${e} API method doesn't seem to support the callback parameter,
+"falling back to call it without a callback: ",o),re,t.fallbackToNoCallback=!1,t.noCallback=!0,n()}else t.noCallback?(re,n()):re})})(m,r[m]);u=a(e,e[m],t)}else u=u.bind(e);else if("object"==typeof u&&null!==u&&(l(t,m)||l(r,m)))u=g(u,t[m],r[m]);else{if(!l(r,""))return Object.defineProperty(s,m,{configurable:!0,enumerable:!0,get:()=>e[m],set(t){e[m]=t}}),u;u=g(u,t[m],r[""])}return s[m]=u,u},set:(t,r,n,o)=>(r in s?s[r]=n:e[r]=n,!0),defineProperty:(e,t,r)=>Reflect.defineProperty(s,t,r),deleteProperty:(e,t)=>Reflect.deleteProperty(s,t)},m=Object.create(e);return new Proxy(m,n)},m=e=>({addListener(t,r,...s){t.addListener(e.get(r),...s)},hasListener:(t,r)=>t.hasListener(e.get(r)),removeListener(t,r){t.removeListener(e.get(r))}}),c=new n(e=>"function"!=typeof e?e:function(t){const r=g(t,{},{getContent:{minArgs:0,maxArgs:0}});e(r)});let u=!1;const d=new n(e=>"function"!=typeof e?e:function(t,s,n){let o,i,a=!1,l=new Promise(e=>{o=function(t){u||(console.warn(r,(new Error).stack),u=!0),a=!0,e(t)}});try{i=e(t,s,o)}catch(e){i=Promise.reject(e)}const g=!0!==i&&(m=i)&&"object"==typeof m&&"function"==typeof m.then;var m;if(!0!==i&&!g&&!a)return!1;const c=e=>{e.then(e=>{n(e)},e=>{let t;t=e&&(e instanceof Error||"string"==typeof e.message)?e.message:"An unexpected error occurred",n({mozWebExtensionPolyfillReject:!0,message:t})}).catch(e=>{console.error("Failed to send onMessage rejected reply",e)})};return c(g?i:l),!0}),f=({reject:r,resolve:s},n)=>{e.runtime.lastError?e.runtime.lastError.message===t?s():r(new Error(e.runtime.lastError.message)):n&&n.mozWebExtensionPolyfillReject?r(new Error(n.message)):s(n)},A=(e,t,r,...s)=>{if(s.length<t.minArgs)throw new Error(Expected at least ${t.minArgs} ${i(t.minArgs)} for ${e}(), got ${s.length}
);if(s.length>t.maxArgs)throw new Error(Expected at most ${t.maxArgs} ${i(t.maxArgs)} for ${e}(), got ${s.length}
);return new Promise((e,t)=>{const n=f.bind(null,{resolve:e,reject:t});s.push(n),r.sendMessage(...s)})},p={devtools:{network:{onRequestFinished:m(c)}},runtime:{onMessage:m(d),onMessageExternal:m(d),sendMessage:A.bind(null,"sendMessage",{minArgs:1,maxArgs:3})},tabs:{sendMessage:A.bind(null,"sendMessage",{minArgs:2,maxArgs:3})}},h={clear:{minArgs:1,maxArgs:1},get:{minArgs:1,maxArgs:1},set:{minArgs:1,maxArgs:1}};return s.privacy={network:{"":h},services:{"":h},websites:{"":h}},g(e,p,s)};if("object"!=typeof chrome||!chrome||!chrome.runtime||!chrome.runtime.id)throw new Error("This script should only be loaded in a browser extension.");e.exports=s(chrome)}else e.exports=browser})?s.apply(t,n):s)||(e.exports=o)},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.fileDownload=void 0;const s=r(0);t.fileDownload=(e,t,r)=>{const n={msg:"download",url:e,filepath:t.replaceAll("",""),filename:r};s.browser.runtime.sendMessage(n)}},function(e,t,r){"use strict";r.r(t),r.d(t,"HTTPError",(function(){return s})),r.d(t,"TimeoutError",(function(){return n}));class s extends Error{constructor(e,t,r){const s=${e.status||0===e.status?e.status:""} ${e.statusText||""}
.trim();super(Request failed with ${s?
status code ${s}:"an unknown error"}
),this.name="HTTPError",this.response=e,this.request=t,this.options=r}}class n extends Error{constructor(e){super("Request timed out"),this.name="TimeoutError",this.request=e}}const o=e=>null!==e&&"object"==typeof e,i=(...e)=>{for(const t of e)if((!o(t)||Array.isArray(t))&&void 0!==t)throw new TypeError("Theoptions
argument must be an object");return l({},...e)},a=(e={},t={})=>{const r=new globalThis.Headers(e),s=t instanceof globalThis.Headers,n=new globalThis.Headers(t);for(const[e,t]of n.entries())s&&"undefined"===t||void 0===t?r.delete(e):r.set(e,t);return r},l=(...e)=>{let t={},r={};for(const s of e)if(Array.isArray(s))Array.isArray(t)||(t=[]),t=[...t,...s];else if(o(s)){for(let[e,r]of Object.entries(s))o(r)&&e in t&&(r=l(t[e],r)),t={...t,[e]:r};o(s.headers)&&(r=a(r,s.headers),t.headers=r)}return t},g="function"==typeof globalThis.AbortController,m="function"==typeof globalThis.ReadableStream,c="function"==typeof globalThis.FormData,u=["get","post","put","patch","head","delete"],d={json:"application/json",text:"text/",formData:"multipart/form-data",arrayBuffer:"/",blob:"/"},f=Symbol("stop"),A=e=>u.includes(e)?e.toUpperCase():e,p=[413,429,503],h={limit:2,methods:["get","put","head","delete","options","trace"],statusCodes:[408,413,429,500,502,503,504],afterStatusCodes:p,maxRetryAfter:Number.POSITIVE_INFINITY},x=(e={})=>{if("number"==typeof e)return{...h,limit:e};if(e.methods&&!Array.isArray(e.methods))throw new Error("retry.methods must be an array");if(e.statusCodes&&!Array.isArray(e.statusCodes))throw new Error("retry.statusCodes must be an array");return{...h,...e,afterStatusCodes:p}};class b{constructor(e,t={}){var r,s,n;if(this._retryCount=0,this._input=e,this._options={credentials:this._input.credentials||"same-origin",...t,headers:a(this._input.headers,t.headers),hooks:l({beforeRequest:[],beforeRetry:[],beforeError:[],afterResponse:[]},t.hooks),method:A(null!==(r=t.method)&&void 0!==r?r:this._input.method),prefixUrl:String(t.prefixUrl||""),retry:x(t.retry),throwHttpErrors:!1!==t.throwHttpErrors,timeout:void 0===t.timeout?1e4:t.timeout,fetch:null!==(s=t.fetch)&&void 0!==s?s:globalThis.fetch.bind(globalThis)},"string"!=typeof this._input&&!(this._input instanceof URL||this._input instanceof globalThis.Request))throw new TypeError("input
must be a string, URL, or Request");if(this._options.prefixUrl&&"string"==typeof this._input){if(this._input.startsWith("/"))throw new Error("input
must not begin with a slash when usingprefixUrl
");this._options.prefixUrl.endsWith("/")||(this._options.prefixUrl+="/"),this._input=this._options.prefixUrl+this._input}if(g&&(this.abortController=new globalThis.AbortController,this._options.signal&&this._options.signal.addEventListener("abort",()=>{this.abortController.abort()}),this._options.signal=this.abortController.signal),this.request=new globalThis.Request(this._input,this._options),this._options.searchParams){const e="?"+("string"==typeof this._options.searchParams?this._options.searchParams.replace(/^?/,""):new URLSearchParams(this._options.searchParams).toString()),t=this.request.url.replace(/(?:?.?)?(?=#|$)/,e);!(c&&this._options.body instanceof globalThis.FormData||this._options.body instanceof URLSearchParams)||this._options.headers&&this._options.headers["content-type"]||this.request.headers.delete("content-type"),this.request=new globalThis.Request(new globalThis.Request(t,this.request),this._options)}void 0!==this._options.json&&(this._options.body=JSON.stringify(this._options.json),this.request.headers.set("content-type",null!==(n=this._options.headers.get("content-type"))&&void 0!==n?n:"application/json"),this.request=new globalThis.Request(this.request,{body:this._options.body}))}static create(e,t){const r=new b(e,t),n=async()=>{if(r._options.timeout>2147483647)throw new RangeError("Thetimeout
option cannot be greater than 2147483647");await Promise.resolve();let e=await r._fetch();for(const t of r._options.hooks.afterResponse){const s=await t(r.request,r._options,r._decorateResponse(e.clone()));s instanceof globalThis.Response&&(e=s)}if(r._decorateResponse(e),!e.ok&&r._options.throwHttpErrors){let t=new s(e,r.request,r._options);for(const e of r._options.hooks.beforeError)t=await e(t);throw t}if(r._options.onDownloadProgress){if("function"!=typeof r._options.onDownloadProgress)throw new TypeError("TheonDownloadProgress
option must be a function");if(!m)throw new Error("Streams are not supported in your environment.ReadableStream
is missing.");return r._stream(e.clone(),r._options.onDownloadProgress)}return e},o=r._options.retry.methods.includes(r.request.method.toLowerCase())?r._retry(n):n();for(const[e,s]of Object.entries(d))o[e]=async()=>{r.request.headers.set("accept",r.request.headers.get("accept")||s);const n=(await o).clone();if("json"===e){if(204===n.status)return"";if(t.parseJson)return t.parseJson(await n.text())}return ne};return o}_calculateRetryDelay(e){if(this._retryCount++,this._retryCount<this._options.retry.limit&&!(e instanceof n)){if(e instanceof s){if(!this._options.retry.statusCodes.includes(e.response.status))return 0;const t=e.response.headers.get("Retry-After");if(t&&this._options.retry.afterStatusCodes.includes(e.response.status)){let e=Number(t);return Number.isNaN(e)?e=Date.parse(t)-Date.now():e=1e3,void 0!==this._options.retry.maxRetryAfter&&e>this._options.retry.maxRetryAfter?0:e}if(413===e.response.status)return 0}return.3*2**(this._retryCount-1)*1e3}return 0}_decorateResponse(e){return this._options.parseJson&&(e.json=async()=>this._options.parseJson(await e.text())),e}async _retry(e){try{return await e()}catch(t){const r=Math.min(this._calculateRetryDelay(t),2147483647);if(0!==r&&this._retryCount>0){await(async e=>new Promise(t=>{setTimeout(t,e)}))(r);for(const e of this._options.hooks.beforeRetry){if(await e({request:this.request,options:this._options,error:t,retryCount:this._retryCount})===f)return}return this._retry(e)}throw t}}async _fetch(){for(const e of this._options.hooks.beforeRequest){const t=await e(this.request,this._options);if(t instanceof Request){this.request=t;break}if(t instanceof Response)return t}return!1===this._options.timeout?this._options.fetch(this.request.clone()):(async(e,t,r)=>new Promise((s,o)=>{const i=setTimeout(()=>{t&&t.abort(),o(new n(e))},r.timeout);r.fetch(e).then(s).catch(o).then(()=>{clearTimeout(i)})}))(this.request.clone(),this.abortController,this._options)}_stream(e,t){const r=Number(e.headers.get("content-length"))||0;let s=0;return new globalThis.Response(new globalThis.ReadableStream({async start(n){const o=e.body.getReader();t&&t({percent:0,transferredBytes:0,totalBytes:r},new Uint8Array),await async function e(){const{done:i,value:a}=await o.read();if(i)n.close();else{if(t){s+=a.byteLength,t({percent:0===r?0:s/r,transferredBytes:s,totalBytes:r},a)}n.enqueue(a),await e()}}()}}))}}The text was updated successfully, but these errors were encountered: