I support the greasemonkey script, which monitors the playback of the current track, as well as progress in Soundcloud. Previously, I could just do require("lib/audiomanager") to access an object that allows me to view the state of the entire page, for example, track information.
The problem is that Soundcloud switched to using webpack for its client-side Javascript. This, as I understand it, saves all these classes as a specific number in the package. The number they store seems to change every time client JS is updated and recompiled.
The only way to access objects stored in webpack seems to be through the global webpackJsonp, as shown below. The package number just needs to be unique.
webpackJsonp([6060], { 0: function (e, t, n) { window.aman = n(726); e.exports = function (abc) { console.log("Exports called"); }; } });
This code will execute and give me access to the object with this number in webpack. The object defined in the JS client web package:
726: function (e, t, n) { (function (t) { function i(e) { var n = t(e.getContainerElement()), i = e.getState() === r.States.ERROR; n.toggleClass('blocked', i) } var r, s = n(53), o = n(14), a = 1000 / 60; e.exports = r = new s({ flashAudioPath: n(2181), flashObjectID: 'flashAudioObject', updateInterval: a, debug: !1 }), r.Errors = s.Errors, r.States = s.States, r.UPDATE_INTERVAL = a, o.once('audio:flash_block audio:flash_unblock', i) }) .call(t, n(1)) },
So, the solutions I can think of:
- Find an object whose web package number does not change, which I can use to get the handle of this object
- Iterate over each web package number and find an object that has the same set of methods as this one.
The latter seems messy, and the first seems impossible. Any ideas?
Things I tried:
- Creating a new n (53), as well as the desired object, occurs, as it seems, for all updates. Gives me an audiomanager, but is definitely separated from the regular page audiomaster, so I donβt see what is playing.