MCPcopy Index your code
hub / github.com/hoothin/UserScripts / getXhr

Function getXhr

Picviewer CE+/dist.user.js:16764–16792  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

16762 let img=imgSpan.querySelector("img,video");
16763 let xhr = dataset(node, 'xhr') !== 'stop' && self.getPropBySpanMark(node, "xhr");
16764 let getXhr = async () => {
16765 let result = await new Promise((resolve) => {
16766 let xhrError = function() {
16767 dataset(node, 'xhr', 'stop');
16768 dataset(node, 'src', dataset(node, 'thumbSrc'));
16769 resolve(null);
16770 };
16771 xhrLoad.load({
16772 url: curNode.dataset.src,
16773 xhr: xhr,
16774 cb: function(imgSrc, imgSrcs, caption) {
16775 if (imgSrc) {
16776 dataset(node, 'src', imgSrc);
16777 dataset(node, 'xhr', 'stop');
16778 if (caption) dataset(node, 'description', caption);
16779 img.dataset.src = imgSrc;
16780 resolve(imgSrc);
16781 } else {
16782 xhrError();
16783 }
16784 },
16785 onerror: xhrError
16786 });
16787 });
16788 imgSpan.removeEventListener('getxhr', getXhrHandler);
16789 delete imgSpan.dataset.xhr;
16790 imgSpan.dispatchEvent(new Event('getxhrover'));
16791 return result;
16792 };
16793 let getXhrHandler = e => {
16794 getXhr();
16795 };

Callers 2

getXhrHandlerFunction · 0.70
initFunction · 0.70

Calls 3

datasetFunction · 0.70
resolveFunction · 0.70
xhrErrorFunction · 0.70

Tested by

no test coverage detected