MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / hook

Function hook

scripts/soundcloud_downloadMusic.js:20–30  ·  view source on GitHub ↗
(obj, name, callback)

Source from the content-addressed store, hash-verified

18 pageScript: {
19 onDocumentStart: async () => {
20 function hook(obj, name, callback) {
21 const fn = obj[name];
22 obj[name] = function (...args) {
23 callback.apply(this, args);
24 fn.apply(this, args);
25 };
26 return () => {
27 // restore
28 obj[name] = fn;
29 };
30 }
31
32 const btnId = "ufs-soundcloud-downloadBtn";
33 const downloadBtn = document.createElement("button");

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected