You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The redirect script ipfs-userscript linked in this repo wasn't working for me, neither the original version, nor the current one, which I had a little help in, so I tried to do it myself. I'm new to JS, so it's in part inspired by the JS code in the currently dormant Safari extension (ipfs-catcher).
Since there's no quick toggle on/off, the script should eventually test if the local node is running, i.e. something like a quick curl to localhost:8080. If it returns "000", the node is inactive, otherwise it's running, i.e. returning "404". (I had already tried it with jQuery.ajax, but it wasn't stable; at first try it didn't redirect, then afterwards it did, but when the node was disabled, it still wanted to redirect to localhost.) So if anyone knows how to easily check for node enabled/disabled in a userscript, I'd be very grateful.
letcheck=newImage();check.onload=onlineHook;check.onerror=offlineHook;// this image is a part of WebUI (load with current timestamp to disable caching)check.src='http://127.0.0.1:8080/ipfs/QmPhnvn747LqwPYMJmQVorMaGbMSgA7mRRoyyZYz3DoZRQ/8f70e85e85c6a23c75c6862292d871c0.png?d='+escape(Date());functiononlineHook(){// enable redirect}functionofflineHook(){// disable redirect}
Brilliant! This seems to have worked… thank you. :) I've left out offlineHook, though. I assume only onlineHook will be necessary.
I've already updated the script, so if you want to include this in this repo's README.md instead of ipfs-userscript (repo: ipfs-redirect-userscript), be my guest.
The redirect script ipfs-userscript linked in this repo wasn't working for me, neither the original version, nor the current one, which I had a little help in, so I tried to do it myself. I'm new to JS, so it's in part inspired by the JS code in the currently dormant Safari extension (ipfs-catcher).
https://github.com/JayBrown/IPRedirect
Since there's no quick toggle on/off, the script should eventually test if the local node is running, i.e. something like a quick curl to localhost:8080. If it returns "000", the node is inactive, otherwise it's running, i.e. returning "404". (I had already tried it with jQuery.ajax, but it wasn't stable; at first try it didn't redirect, then afterwards it did, but when the node was disabled, it still wanted to redirect to localhost.) So if anyone knows how to easily check for node enabled/disabled in a userscript, I'd be very grateful.
See also the related question here: http://stackoverflow.com/questions/43901231/ipfs-javascript-check-for-404-status-from-localhost8080-to-determine-in-brow
The text was updated successfully, but these errors were encountered: