========= other macro: image toggle with JAVASCRIPT ========
Quote
anonymous
Had removeAttribute in the macro and not src=null. Not touching broken images to prevent reload attempts. No problems with different domains. Need a test site and some modifications to test this in KM 1.x. versions.
Am not sure if KM1.x really has bigger probs as KM7x in this case, but may be, haven't tested yet except with KM74.
Just so many bugs and probs everywhere, sigh.... Must admit, after having wasted far too much time trying to get that pesky offline-toggle included, and running again and again against that old wall of macrolanguage+JS bugs and engine RESTRICTIONS and XXS barriers etc (worst bug: zero chance to toggle a setting, running a bit JS, then toggling back), have now currently moved back again to some other macros. Of my big pile of unfinished macros with a much higher priority as this one, which has at least already a basic 2-command solution (toggle+reload). Not the fastest way, but by far the only reliable solution. Somehow most of that stuff starts out as a tiny cute 10-20 line js-scriptlet at the beginning, then various probs or even just imaginable future probs start emerging, and the tiny new macros start growing, growing, growing into a monster, sometimes even exploding up to novel size, with 30 menu lines or more... And as soon as one prob is finally solved, another one starts showing up, or even two! It never ends, grmpf.
Anyway, for now have put this one on the backburner. Although a rough js-version is already working (stylekiller method, just toggling ALL src tags empty/filled, plus 1-level iframes), and basically just needs a permanent pref toggle included before posting a first Beta version. Adding the pref should be easy, still planning to post this in a while. But otherwise that macro will be absolutely imperfect, and remain so. Just too many unsolvable problems for a general image toggle by handling single images.
One of the worst is forbidden XSS access for macros/userscripts in iframes of other (sub)domains. Although websites can happily crosslink scripts and load stuff as much as they like, from any (evil) foreign domains they want, and even embed invisibly whole pages from other domains. But USERS (macro-scripts) are forbidden to even ask for the contentWindow-location of an iframe, if it doesn't have the exact same domain, and that even means the exact same SUBdomain! (just as example that even the most harmless things are forbidden, am aware that macros get at least the $FrameURL - but not by script)
Wonder if that permission prob may have gotten better meanwhile in KM76? Perhaps at least all subdomains now accessible, from www.domain.com? Until now have only tried in KMG74, which still suffers from the exact same bugs and lacking permissions as KM1.x
Sadly such missing privileges for macro-scripts, plus killer bugs in JS or macrolanguage, have meanwhile killed most of my macros. And also some completely unnecessary macro restrictions, like being allowed to transfer only a ridiculously tiny 4kB string from injectJS back into macros, or max 64kB for readfile, or min 1 second for a js-timer, etc. All those probs are wasting 90% of my writing time, along with missing JS skills, both killing nearly all fun too
Sorry for the novel. Just so frustrating and such a waste of time, with far too few finished macros.
But back to this image toggle, why I don't hold much hope for it. Even without any iframe probs, there are just so many special probs involved with toggling images by JS:
single ones may be broken, others may be blocked, some can be dynamically created, switching the source when users do a certain action, or depend on screen size etc. Yet another one: background images. Have attached an example.
Not sure how many of those complicated probs could eventually be worked around. Hardly by myself, extremely slow due to lack of JS skills, and would surely grow the thing into another monster macro - and in the end still buggy (while other macros with *much* higher priority never get finished)
But in general I see not enough need for this JS-method anyway. So my current plan is to some day post just the basic version which is nearly finished already, for simple quick non-perfect toggles. If a more reliable function is needed, users can simply toggle the pref and reload, as before, no prob at all.
That only thing which could have made this perfect is to include an offline-toggle in the tiny 2-command-macro. Un extremely simple thing, but doesn't work due to old JS/macro bugs. And whatever workarounds and tricks I could think of so far, trying long and hard, still no chance
Really should better spend this time on highly important other macros.