MCPcopy Index your code
hub / github.com/ClearURLs/Addon / importSettings

Function importSettings

core_js/settings.js:258–280  ·  view source on GitHub ↗

* This function imports an exported ClearURLs setting and overwrites the old one.

(evt)

Source from the content-addressed store, hash-verified

256 * This function imports an exported ClearURLs setting and overwrites the old one.
257 */
258function importSettings(evt) {
259 let file = evt.target.files[0];
260 let fileReader = new FileReader();
261
262 fileReader.onload = function (e) {
263 let data = JSON.parse(e.target.result);
264 const length = Object.keys(data).length;
265 let i = 0;
266
267 Object.entries(data).forEach(([key, value]) => {
268 browser.runtime.sendMessage({
269 function: "setData",
270 params: [key, value]
271 }).then(() => {
272 i++;
273 if (i === length) {
274 location.reload();
275 }
276 }, handleError);
277 });
278 };
279 fileReader.readAsText(file);
280}
281
282function handleResponse(message) {
283 console.log(`Message from the background script: ${message.response}`);

Callers

nothing calls this directly

Calls 3

forEachMethod · 0.80
entriesMethod · 0.80
keysMethod · 0.45

Tested by

no test coverage detected