MCPcopy Create free account
hub / github.com/Tampermonkey/tampermonkey / wrap

Function wrap

src/environment.js:107–117  ·  view source on GitHub ↗
(source)

Source from the content-addressed store, hash-verified

105 }
106
107 var wrap = function(source) {
108 // TODO: is there another way than generating this code?
109 var s = "";
110 s += 'try {\n';
111 s += requires + source + '\n';
112 s += '} catch (e) {\n';
113 s += ' console.log("ERROR: Execution of script \'' + script.name + '\' failed! " + e.message); \n';
114 s += ' console.log(e.stack.replace(/\\(eval at <anonymous> /g, "").replace(/<anonymous>:/g, "").replace(/chrome-extension:\\/\\/[\\w]{32}\\/content\\.js:\\d*:\\d*\\)*, /g, ""))\n';
115 s += '}\n';
116 return s;
117 };
118
119 setid = 'arguments.callee.setID({ id: "' + script.id + '", run_at: "' + script.options.run_at + '", ns: "' + script['namespace'] + '" });\n';
120

Callers 2

TM_mEvalFunction · 0.70
TM_addEventListenerFixFunction · 0.70

Calls 3

postLoadEventFunction · 0.85
postDomEventListenerFunction · 0.85
refireAllNodeInsertsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…