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

Function getSaveParams

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

Source from the content-addressed store, hash-verified

15212 eleMaps['head-command-drop-list-others'].querySelector('input[data-command="scrollToEndAndReload"]').checked = prefs.gallery.scrollEndAndLoad;
15213 let srcSplit, downloading=false, saveParams;
15214 async function getSaveParams() {
15215 let nodes = self.eleMaps['sidebar-thumbnails-container'].querySelectorAll('.pv-gallery-sidebar-thumb-container[data-src]:not(.ignore)');
15216 let saveParams = [],saveIndex=0;
15217 for (const node of nodes) {
15218 if (unsafeWindow.getComputedStyle(node).display !== "none") {
15219 saveIndex++;
15220
15221 let xhr = dataset(node, 'xhr') !== 'stop' && self.getPropBySpanMark(node, "xhr");
15222 if (xhr) {
15223 self.showTips("Sending request...", 3000);
15224 await new Promise(resolve => {
15225 setTimeout(() => {
15226 let xhrError = function() {
15227 dataset(node, 'xhr', 'stop');
15228 dataset(node, 'src', dataset(node, 'thumbSrc'));
15229 resolve();
15230 };
15231 xhrLoad.load({
15232 url: node.dataset.src,
15233 xhr: xhr,
15234 cb: function(imgSrc, imgSrcs, caption) {
15235 if (imgSrc) {
15236 dataset(node, 'src', imgSrc);
15237 dataset(node, 'xhr', 'stop');
15238 if (caption) dataset(node, 'description', caption);
15239 resolve();
15240 } else {
15241 xhrError();
15242 }
15243 },
15244 onerror: xhrError
15245 });
15246 }, prefs.gallery.downloadGap || 0);
15247 });
15248 }
15249
15250
15251 if (node.dataset.src.indexOf('data') === 0) srcSplit = "";
15252 else {
15253 srcSplit = node.dataset.src || '';
15254 }
15255 let title = node.title.indexOf('\n') !== -1 ? node.title.split('\n')[0] : node.title;
15256 title = title.indexOf('http') === 0 || title.indexOf('data') === 0 ? '' : title;
15257 title = getRightSaveName(srcSplit, title, prefs.saveName);
15258 let picName = (saveIndex < 10 ? "00" + saveIndex : (saveIndex < 100 ? "0" + saveIndex : saveIndex)) + (title ? "-" + title : ""), hostArr = location.host.split(".");
15259 let host = hostArr[hostArr.length-2];
15260 saveParams.push([node.dataset.src, picName]);
15261 if (node.dataset.srcs && node.dataset.srcs != node.dataset.src) {
15262 node.dataset.srcs.split(",").forEach(src => {
15263 saveParams.push([src, picName]);
15264 });
15265 }
15266 //saveAs(node.dataset.src, location.host+"-"+srcSplit[srcSplit.length-1]);
15267 }
15268 }
15269 return saveParams;
15270 }
15271 self.openImages = (e) => {

Callers 1

initFunction · 0.70

Calls 4

datasetFunction · 0.70
resolveFunction · 0.70
xhrErrorFunction · 0.70
getRightSaveNameFunction · 0.70

Tested by

no test coverage detected