« first day (4027 days earlier)      last day (904 days later) » 

12:12 AM
ok I think I found my mistake. I need to find a way to store the initial offset of my navbar otherwise the current one would never be greater than the page offset.
 
12:33 AM
Bingo! Goodnight everyone!
 
user16940297
1:18 AM
Kevin.
 
user16940297
How do I know that removeEventListener was successful?
Is there a way to confirm that removeEventListener was successful?
 
3:39 AM
Is anyone here?
 
@Badmaash Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
2 hours later…
5:50 AM
@htmlcssjava3456 The only indication would be if the event listener doesn't trigger any more. removeEventListener() itself only returns undefined and not any indication of whether something was removed or not.
 
 
3 hours later…
8:52 AM
In the second paragraph "Comparing both sets of code above, the functional component has significantly simpler code that performs the same function;" - it's literary 3 keywords difference, if that's significant...
 
@PéterLanszki Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
9:31 AM
is anyone available to call me an idiot?
I am trying to hack the internet and cant figure out how
 
you need the right axe
 
hmm... perhaps I do
I am trying to make a web user input listener (basically record what the user does, click on stuff, type stuff, etc)
it mostly works, but there is a small problem with my redirect detection
if the user were to go to a url using the url bar of the browser (not using a click on a button or [enter] which triggers a submit) then I do get an event that the page is unloaded (beforeunload) but I dont get any event containing any information where I would be going to
currently, I just reconnect the listener and read the url at that point and register that the user went to that url
however, that wont work if the url you go to is different than the url you were redirected to
 
Wait where are you doing this?
a website isn't supposed to know that
 
9:48 AM
I inject a listener script (which listens to beforeunload, keyup|press|down, mouseup|down, etc) and sends json objects with relevant information to localhost (a http server that collects those events)
 
Yeah, knowing where the user goes to would be a big breach of privacy.
 
when the beforeunload happens, I send the event of a redirect, the server then injects the listener script again and reads the url that you redirected to
 
Wait, do you control both the origin and destination URL?
 
nope
I control the browser
 
Ah, I see.
 
9:49 AM
So you are a writing a plugin?
 
I am using selenium, chromedriver and chromium
not a plugin, no, I hope to avoid that
I want to make a recorder to record user actions
 
You probably can get this information through the plugin API of Chrome/FF/whatever. But I'm not too familiar with those. OK scratch that
 
similar to how the selenium ide can record your actions
 
I doubt you can without a plugin - as that would always open the possibility for privacy issues.
 
The Selenium IDE is a plugin, though. So, that's probably how it records actions.
 
9:52 AM
true, I try to do it without the use of a plugin
hence I am making this myself
 
I think you're more limited then but there is some options. I'm not sure you need the destination. You can just capture what was done on the page and replay it. That's sort of what the Selenium IDE does. So you won't know where a button might lead (e.g., if you click it and you're redirected) but you'd know that pressing the button makes the page not be there yet. If you're recording the actions of a user, you can keep a session ID and you'd know on which page the session continued.
So, you'd get something like
Session 123 -> On page abc.html
Session 123 -> click button Foo
Session 123 -> redirect to new page
Session 123 -> On page xyz.html
Session 123 -> <do more stufff>
 
yes, except "if the user were to go to a url using the url bar of the browser (not using a click on a button or [enter] which triggers a submit)"
if I type "http://google.com" in the url bar, the page unloads, I reconnect the listener and the url is https://www.google.com/?gws_rd=ssl at that time... which works mostly now, but it would possibly break if it were to contain session data or timestamps or something
maybe I could try to just spam "getUrl" from when the unload happens until it changes
but that would still be a hack...
I was also thinking about maybe if one tab opens another tab, it might have more permissions and receive additional events, but google ain't giving me useful results
 
 
6 hours later…
3:37 PM
why do so many blogs suggest using axios --- in 2021
If you check the github for axios you notice that they basically imply that enabling http/2 is so hard it would be a complete rewrite and no progress is done in 3 years in that regard.
And while http/2 might not be a "requirement" now, using a library that implies it won't ever start handling http/2 is like suggesting in the early 2000s/2010s to not use https/use libraries that won't support secure transmissions.
It is "soon" outdated and you create a dependency on something that won't be future proof.
 
is there anything nice on top of fetch that has a better API? (like python requests, which is very similar to axios' API)
 
There seems to be "got" but that is backend only
 
for example i really miss something like fetch('/foo', {query: {a: 123, b: 456}}); to query /foo?a=123&b=456. having to create an URLSearchParams object first is cumbersome and ugly.
 
Well the big problem is that people suggest: "use axios and also use it on the backend".
 
@paul23 Which is a very weird suggestion. If you have a JS frontend and, say, Java backend you wouldn't have the same tech on both. I'm not sure it's really needed if it's JS/JS. Oh sure, you save a slight bit of learning if it's the same thing in both places but realistically, there isn't that much of a learning curve to libraries that do HTTP calls. If you know what call you want, you can use any library.
 
3:46 PM
On the browser axios will obviously use http/2 if the server and browser use http/2. (which ironically means you cannot use express in node :P)
Which is one of the big drawbacks on express as well btw
In express it seems to be locked behind: "we want too much for express 5.0"
 
just add more dependencies
what could go wrong?
 
:P
Thing is though: if a single point in the stack doesn't handle http/2, nothing will
 
4:13 PM
something doesn't look right here:
spdy.createServer(
  {
    key: fs.readFileSync("./server.key"),
    cert: fs.readFileSync("./server.crt")
  },
  app
).listen(8000, (err) => {
  if(err){
    throw new Error(err)
  }
  console.log("Listening on port 3001")
})
 
> "Listening on port 3001"
|| chinese or pizza or burger
 
burger
 
4:49 PM
i started with Generals Cry shield crush, and determined that it didn't fit my playstyle. I've now leveled a steel skills champ, and it's blasting. unfortunately the weapon i need for the build is very expensive, so... gonna be running the lower dam version of it for a while. Need a saviour, using a temp est for now. Might switch to 2x ichi or ichi + paradoxica if it takes too long to get saviour
 
You started trade league, right?
Also, I took too long to order a burger (forgot to click the "order" button) and now the burger place is closed. Well, pizza it is then.
 
5:07 PM
I have this piece of HTML:
<script>
    const currentSong = <%- JSON.stringify(locals.song) %>
</script>
It's giving me an Expression expected. error. Can I get a hand?
 
yea, trade league
0 ex so far, and nothing worth an ex. I do have a pair of onslaught life/resist 30% movespeed boots though... in their current form they're worth 40-50c, but if i could corrupt movespeed onto it..
think ima just take the 40c rather than risk bricking it
40c would bring me up to about an ex in chaos, i need 10ex+ for my weapon upgrade
 
@AnnZen What is the content of JSON.stringify(locals.song)? I assume it's something that doesn't serialise to valid JS code. You might need const currentSong = "<%- JSON.stringify(locals.song) %>" (although if locals.song has a " you might get an error).
 
yeah that error tells me <%- JSON.stringify(locals.song) %> is somehow flawed
 
At least I assume that whatever template that is replaces %- JSON.stringify(locals.song) %> with just the content inside. You should look at the output of that and see what you actually get out of the template.
 
or isn't meant to produce javascript object literals
 
5:24 PM
anyone else cringe when they see "...added a javascript to the website"
 
i've never seen that before
but seeing it now just made me think maybe the user's first language isn't english... which isn't necessarily a concern
 
fair lol, i thought more on lines of doesn't know what JS is
 
6:02 PM
@VLAZ Thanks for the reply! I'm not sure it's relevant, because the editors shows that the <% - seems to be invalid syntax: i.stack.imgur.com/lT6LG.png
 
@AnnZen Oh...I assumed it was some sort of templating engine. That's not actually any vanilla JS syntax, so if you don't have anything that processes it, it won't work.
 
@VLAZ oh i see.
@VLAZ do you know of any alternative?
 
You can do an AJAX call to the server to get the song name. Although I'm not exactly sure what locals is supposed to be and where it is - client or server. If it's something in the client, then you don't need the <%- %>
 
 
1 hour later…
7:17 PM
   const renderdata = (data) => {
      return data.stuff;
    }

    const renderdata = (data) => {
      return <span>{data.stuff}</span>;
    }
 
@default_noob_network Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
so the top one works. the second one doesnt......
why?
the second one just renders [object Object]
 
7:28 PM
||> ({}).toString()
 
@JBis 'SyntaxError: Unexpected token \'.\'' Logged: [ ] Took: 0ms
@JBis '[object Object]' Logged: [ ] Took: 0ms
 
|| mdn json stringify
 
 
2 hours later…
9:12 PM
thanks
 
9:29 PM
my knowledge of javascript makes responding to some obvious things difficult
> it isn't possible for... wait, no, it is possible if you do these stupid workarounds that should never be done
 
@KevinB I tend to keep it short with something like "Not possible in a useful way". Although, I find that a lot of times it's just an XY problem and often I just ask what is the actual problem being solved.
Some times it's just misunderstanding. Recently had somebody who asked an XY question because they fundamentally misunderstood some part of the language and thought it's not suitable for doing X.
 
in this case it was something very simple, but knowing what they're claiming is happening is possible made me hesitate
;)
given the code they've provided and problem they're having, there's zero chance they've created the nightmare scenario
 
Ah yes, the question that is like "Help, I have warped reality and now JavaScript works different for me than for anybody else" which might be a weird situation they've created or maybe they just didn't read the logs properly and assumed something else happened.
 
@KevinB in that case, you can probably help me :)
I need a stupid workaround
that should never be done
 
lol
 
9:40 PM
( ͠° ͟ʖ ͡°)
 
but I probably have to make a plugin in order to make it work
but I dont want to
 
9:56 PM
generally speaking, I want to record browser user input (like click on a button, write text in an input field, etc)
I am aware of SeleniumIDE's recording feature, which is practically what I want, just without the SeleniumIDE around it
not sure what the best approach to it would be
 
there's definitely some obstacles to overcome
for most interactions, general event handlers on body will catch all events, so you can tell where the mouse is, where it was when a click happened, what input has focus, but then you start getting into a messy territory where event handlers the page has bound could be preventing the event from bubbling up the dom
there's also event capturing, but i've never messed with that
 
Just thinking out loud here; is it possible to override addEventListener's prototype before any userland calls, and like, essentially manually wrap each and every one of them?
some kind of event listener middleware by forcing further scripts to call our doctored addEventListener
 
@FélixAdriyelGagnon-Grenier yes, but you're likely to regret it
 
oh yeah, would it even be javascript otherwise?
 
@FélixAdriyelGagnon-Grenier Only if you run some code before everything else and you overwrite addEventListener. But as @phenomnomnominal says, it's probably a bad idea.
 
10:10 PM
oh, no way I'm going to do it, it was a bad suggestion for @Wietlol so that I can learn from their mistakes
 
@VLAZ I have one more question. Can I ask?
 
@AnnZen sure
 
i mean, of course it's possible
by design
 
that's pretty cool now that I think about it
 
10:13 PM
I guess "before any userland calls" might be impossible. Someone could always add a proxy or extension or whatever and inject shit before your monkeypatch script.
 
Node.prototype.addEventListener = function () { console.log('foobar'); }
 
Also Node isn't the only interface that implements EventListener and that could get very messy
 
do that here and every new message will cause foobar to appear in console
 
so like, by "saving" the original function in a closure one could effectively like
 
aka monkeypatch
 
10:15 PM
yep
 
(is that term still socially acceptable?)
 
Node.prototype.eventListener = (() => {
    const original = Node.prototype.eventListener;
    return () => {
        // do shit
    };
})();
 
@phenomnomnominal Please don't post unformatted code - use the up arrow to edit your post, then hit Ctrl + K to format the code in that post. See the faq. You have 25 seconds to edit and format your message properly before it will be removed. Please separate code blocks from your actual question. Put your question in 1 message and then your code in a 2nd and format it.
 
(dunno, it rings bells in the python parts of my memory as well)
 
10:16 PM
@KevinB I've not seen objections against it yet.
 
> The term monkey patch seems to have come from an earlier term, guerrilla patch, which referred to changing code sneakily – and possibly incompatibly with other such patches – at runtime. The word guerrilla, homophonous with gorilla (or nearly so), became monkey, possibly to make the patch sound less intimidating.
 
@phenomnomnominal nice
 
NOT NICE DON'T DO IT :P
 
:P
too late, you are now the parent of that snippet of code. it will come to haunt you
 
@VLAZ In this code:
 
10:18 PM
oh i'm haunted af already
also procrastinating
 
<script>
    const currentSong = <% anything %>
</script>
 
writing docs is hard
 
it seems that whatever I replace the "anything" with, for example the number 10, it gets parsed out as
<script>
    const currentSong =
</script>
causing the Uncaught SyntaxError: Unexpected end of input error.
Any idea of what could be causing it?
 
What is processing <%
 
10:20 PM
Better check the documentation of whatever provides the interpolation of <% anything %> You might need something like <% return anything %> or something else.
 
@FélixAdriyelGagnon-Grenier definitely not the worst pin I've had in this room
lol that I'm still a room owner??
 
@VLAZ the "anything" is just a placeholder I put in.
 
I'm not sure what works with <% %> but it seems like some sort of templating or otherwise processing.
 
yeah... we haven't cleared out room owners... since the event
¯\_(ツ)_/¯
 
@AnnZen Yes, I mean perhaps you need return in the <% %> but I'm just guessing.
 
10:22 PM
<% ... %> doesn't have any meaning in html or javascript
 
@KevinB what was the event????
 
Evidently <% anything %> is currently processed and removed. But not replaced with any of its content.
 
the whole... 2018 -> 2019 mess
that had everyone move on
 
@VLAZ I'm following this video, and timestamped the relevant part: youtube.com/watch?v=d0-VH4MC0Rk&t=2276s
In 5 seconds you'll see what I'm trying to do.
*I'm trying to access a variable from a js file in the ejs file.
 
@KevinB oh everyone being babies about the suggestion that this (very toxic) place is toxic?
can someone fill this out for me?
 
10:26 PM
OK, so it's some sort of templating engine, it seems. In the server the guy does res.render("index", {song: song}) which should (I'm guessing) take the index template and pass {song: song} to it which then becomes locals in that template.
The guy mentiones you need - in <%- %> so, I'm going to trust him. If that still doesn't produce anything, then perhaps there is something in the setup earlier on that's wrong.
 
If it’s ejs, that should have some docs that would clear this right up
But I’m hitting the road, won’t be back till later
 
@KevinB currently, I just start a new chrome session with chromedriver and inject a script that listens to beforeunload, keypress and mouseup (which might be better as mousedown)
 
@phenomnomnominal "Why are bananas curved?"
I'm not actually sure what should be filled in.
 
in any case, the script will then send the event with relevant information to localhost:port/events where a http server is running to collect all the events
the problem is then that some websites wont allow sending http requests to localhost
 
I'm going to use my sharks/saturn fact
 
10:29 PM
@VLAZ okay, thanks.
 
on the beforeunload event, the chromedriver injects the script again on the new page which re-registers the listeners
that way, I follow through the redirects
I dont really have a way to register when a user goes to a url by typing it in the url bar, but that should probably not be necessary if we just have an initial url
 
this is so dumb - if I had a good idea for a question about my talk I would answer it in my talk.
 
@phenomnomnominal oh, no, I was finding the pin to have very high humoristical timing and efficiency, making me let out a honest chuckle
 
@FélixAdriyelGagnon-Grenier haha nah I mean I am lolling that I am still a RO
Oh, but the good thing about that is that I can...
✨✨✨
 
Kevin B. has removed phenomnomnominal from the room owners list
 
10:43 PM
I'll kick you :P
 

« first day (4027 days earlier)      last day (904 days later) »