-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wsHook.before/after not triggering #5
Comments
I've changed my code a bit to make sure I was okay on my end. // make websocket hook
let websockethook = document.createElement('script');
websockethook.setAttribute('type', 'text/javascript');
document.body.appendChild(websockethook);
websockethook.onload = () => {
wsHook.before = function (data, url) {
console.log("Sending message to " + url + " : " + data);
return data;
}
}
websockethook.setAttribute('src', 'https://cdn.rawgit.com/skepticfx/wshook/master/wsHook.js'); In the console |
Well, that's unfortunate, just tested in chrome and firefox (not with echo but the site I'm looking at) same way you did with no luck. |
can you point me to the website or the open source code? Would love to make it work. I want to support socket.io when I get a chance. |
Also, what is your use case here? :) |
Website is https://idle.land with the source code at https://github.com/IdleLands/IdleLands/ So far it looks as though it is using socketcluster-client for creating the websocket. From what I've seen socketcluster-client uses the normal WebSocket constructor, but I'm still learning this stuff as I go. |
Well, I've found the issue. The wshook was created after the websocket had already been made. |
Sorry I missed this. Am glad it works now. Where are you adding those |
I'm using tampermonkey for the user script, so just in the script's header. // ==UserScript==
// @name wsHook Test
// @version 1
// @grant none
// @require https://cdn.rawgit.com/skepticfx/wshook/master/wsHook.js
// @run-at document-start
// @match https://play.idle.land/*
// ==/UserScript==
wsHook.before = function (data, url, wsObject) {
return data;
}
wsHook.after = function (data, url, wsObject) {
return data;
} Also worth noting, if you change No worries anyways, simple fix and it looks very clean in the end. |
I see. Thanks @BrightSchema. |
I have this code to inject the script into the page once loaded. I can access wsHook from the console, however before/after never trigger.
Am I missing a step or is this not a possible implementation?
The text was updated successfully, but these errors were encountered: