The browser does not know the path. Also, if the function (or one of its parents) is in a closure, there may not even be a path to the function from window.
If you're sure the function is reachable from window you can search for it recursively:
(function () {
function search(prefix, obj, fn, seen = null) {
if (!seen) seen = new Set();
// Prevent cycles.
if (seen.has(obj)) return false;
seen.add(obj);
console.log('Looking in ' + prefix);
for (let key of Object.keys(obj)) {
let child = obj[key];
if (child === null || child === undefined) {
} else if (child === fn) {
console.log('Found it! ' + prefix + '.' + key);
return prefix + '.' + key;
} else if (typeof child === 'object') {
// Search this child.
let res = search(prefix + '.' + key, child, fn, seen);
if (res) {
return res;
}
}
}
return false;
}
// For example:
let fn = function() { alert('hi'); }
window.a = {};
window.a.b = {};
window.a.b.c = {};
window.a.b.c.f = fn;
return search('window', window, fn);
})();
This is using my gameboy emulator, binjgb[0], on the website! (well one of my gameboy emulators, heh [1][2]) It's been used as the emulator for GB Studio for a little while now, but I don't know how often people embed it in their websites, so it's really cool to see.
Oddly, I'm the opposite. Working in devops and vscode, I find the visual aspect of color and logical formatting improves my work dramatically. Small tools like "bat" vs. "cat" on the terminal are great at quick data parsing for things like yaml, json, and the like. Staying old school for the sake of old school is a bit of a fallacy IMHO.
> I have a mailing list for people who use my code, when an update is out they can download the .php files, 'require' them and test them before deployment, but never will I do packages.
This offers no benefit in terms of security, over a package dependency locked at a specific version.
The end result is the same: the user ends up downloading the .php files, and testing them in deployment, but through composer instead of curl.
It doesn't contribute to security at all, it just makes it awkward for other people to use your code.
Cool article, but I'm not impressed by DropBox's upload speed on my Windows computer, at all.
I just tested rn with DropBox, GoogleDrive, and OneDrive, all with their native desktop apps. I simply put a 300MB file in the folder and let it sync.
DB: 500 KiB/s
GD: 3 MiB/s
OD: 11 MiB/s (my max bandwidth with 100Mbps)
I don't know what causes the disparity here, but I have been annoyed by this for years, and it's the same across multiple computers I use at different locations.
Another funny thing is if you just use the webpage, both GD and DB can reach 100Mbps easily.
Edit: should mention Google's DriveFS can reach max speed too, but it's not available for my personal account (which uses the "Backup and sync for Google" app).
If you're sure the function is reachable from window you can search for it recursively: