MCPcopy
hub / github.com/Tampermonkey/tampermonkey / restoreAllScriptsEx

Function restoreAllScriptsEx

src/background.js:163–224  ·  view source on GitHub ↗
(processSource, cb)

Source from the content-addressed store, hash-verified

161 var version = determineOldVersion();
162
163 var restoreAllScriptsEx = function(processSource, cb) {
164 var d = new scriptParser.Script();
165 var names = getAllScriptNames();
166 var running = 1;
167 var check = function() {
168 if (--running == 0 && cb) {
169 window.setTimeout(cb, 1);
170 }
171 };
172
173 for (var k in names) {
174 var wrap = function() {
175 var n = names[k];
176 var r = loadScriptByName(n);
177 if (!r.script || !r.cond) {
178 console.log(I18N.getMessage("fatal_error") + " (" + n + ")" +"!!!");
179 return;
180 }
181 for (var kk in d.options) {
182 if (!d.options.hasOwnProperty(kk)) continue;
183
184 if (r.script.options[kk] === undefined) {
185 console.log("set option " + kk + " to " + JSON.stringify(d.options[kk]));
186 r.script.options[kk] = d.options[kk];
187 }
188 }
189 for (var e in d.options.override) {
190 if (r.script.options.override[e] === undefined) {
191 console.log("set option.override." + e + " to " + JSON.stringify(d.options.override[e]));
192 r.script.options.override[e] = d.options.override[e];
193 }
194 }
195
196 var time = function() {
197 r.script = mergeCludes(r.script);
198
199 if (processSource) {
200 var ss = { url: r.script.fileURL,
201 src: r.script.textContent,
202 ask: false,
203 cb : function() { /* done! */ },
204 hash: r.script.hash };
205 addNewUserScript(ss);
206 } else {
207 r.script.id = scriptParser.getScriptId(r.script.name);
208 storeScript(r.script.name, r.script, false);
209 }
210
211 check();
212 };
213 if (cb) {
214 running++;
215 window.setTimeout(time, 10);
216 } else {
217 time();
218 }
219 };
220 wrap();

Callers 2

resaveAllScriptsExFunction · 0.85
convertDataFunction · 0.85

Calls 3

getAllScriptNamesFunction · 0.85
checkFunction · 0.85
wrapFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…