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

Function init

src/content.js:1122–1196  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1120
1121var initW = 1;
1122var init = function() {
1123 var Femu = "emulation.js";
1124 var Fenv = "environment.js";
1125 // var Fjslint = "jslint.js";
1126
1127 var updateResponse = function(resp) {
1128 if (resp === undefined) {
1129 if (D) console.log("content: _early_ execution, connection to bg failed -> retry!");
1130 window.setTimeout(init, initW);
1131 // avoid too much load in case something is really b0rken!
1132 initW *= 2;
1133 return;
1134 }
1135
1136 // register listeners for eventing... context ID now is 'stable'
1137 Eventing.init();
1138
1139 logLevel = resp.logLevel;
1140 adjustLogLevel();
1141
1142 if (V || D) console.log("content: Started (" + Eventing.contextId + ", " + window.location.origin + window.location.pathname + ")");
1143
1144 if (allReady) {
1145 // env is already executed -> set loglevel
1146 _handler.sendMessage("TMwin.adjustLogLevel(" + logLevel + ");\n");
1147 }
1148 if (resp.enabledScriptsCount) {
1149 if (V || D) console.log('content: start event processing for ' + Eventing.contextId + ' (' + resp.enabledScriptsCount + ' to run)');
1150 wannaRun = true;
1151
1152 /* if (!emu || !env || !jslint) {
1153 emu = resp.raw[Femu] || emu;
1154 env = resp.raw[Fenv] || env;
1155 jslint = resp.raw[Fjslint] || jslint || "";
1156 } */
1157
1158 if (resp.webRequest) {
1159 _webRequest = resp.webRequest;
1160 xmlhttpRequestHelper.setWebRequest(_webRequest);
1161 if (_webRequest.headers && !_webRequest.verified && xhrRetryCnt-- > 0) {
1162 forceTestXhr();
1163 }
1164 }
1165
1166 secondStage.runHlp();
1167 } else {
1168 if (V || D) console.log('content: disable event processing for ' + Eventing.contextId);
1169 wannaRun = false;
1170 allReady = true;
1171 secondStage.cleanupHlp();
1172 cleanup();
1173 }
1174 };
1175
1176 var raw = [];
1177 try {
1178 emu = '(' + Registry.getRaw(Femu) + ')();\n';
1179 env = '(' + Registry.getRaw(Fenv) + ')();\n';;

Callers 1

content.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…