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

Function HTM_runMyScript

src/environment.js:782–1247  ·  view source on GitHub ↗
(HTM_request)

Source from the content-addressed store, hash-verified

780};
781
782var HTM_runMyScript = function(HTM_request) {
783 var TM_storage_listeners = [];
784 var TM_context_storage = HTM_request.storage;
785 var TM_context_name = HTM_request.script.name;
786 var HTM_script = HTM_request.script;
787 var nop = function(response) {};
788 var storagePort = null;
789
790 var HTM_getInfo = function() {
791 var excl = { 'observers' : 1,
792 'id': 1,
793 'enabled': 1,
794 'hash' : 1,
795 'fileURL' : 1 };
796 var o = { script: {} };
797
798 for (var k in HTM_script) {
799 if (!HTM_script.hasOwnProperty(k) || excl[k]) continue;
800 o.script[k] = HTM_script[k];
801 }
802
803 // GM_info compatibility
804 o.script['run-at'] = HTM_script['options'].override.run_at || HTM_script['options'].run_at;
805 o.script['excludes'] = HTM_script['options'].override.orig_excludes;
806 o.script['includes'] = HTM_script['options'].override.orig_includes;
807 o.script['matches'] = HTM_script['options'].override.orig_includes;
808 o.script['unwrap'] = false;
809
810 o['scriptMetaStr'] = HTM_request.header;
811 o['scriptSource'] = HTM_request.code;
812 o['scriptWillUpdate'] = !!(HTM_script['options'].fileURL && HTM_script['options'].fileURL != "");
813 o['scriptUpdateURL'] = HTM_script['options'].fileURL;
814 o['version'] = HTM_request.version;
815 o['scriptHandler'] = "Tampermonkey";
816
817 return o;
818 };
819
820 var HTM_initStoragePort = function() {
821 var storageListener = function(response) {
822 if (response.storage) {
823 for (var k in response.storage.data) {
824 if (!response.storage.data.hasOwnProperty(k)) continue;
825 var run = function() {
826 var key = k;
827 var oldval = TM_context_storage.data[k];
828 TM_context_storage.data[k] = response.storage.data[k];
829 var newval = TM_context_storage.data[k];
830 if (V) console.log("env: storageListener - config key " + key + ": " + oldval + " -> " + newval);
831 TM_notifyValueChangeListeners(key, oldval, newval, true);
832 };
833 run();
834 }
835 }
836 if (response.removed) {
837 TM_context_storage[response.removed] = undefined;
838 }
839 if (response.error) {

Callers 1

rFunction · 0.85

Calls 4

HTM_initStoragePortFunction · 0.85
TM_mEvalFunction · 0.85
runFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…