« first day (1993 days earlier)      last day (2969 days later) » 

6:00 PM
that's why you buy a boat, so you can fill it up
 
@ssube a 4 switched with a 5 in the middle of some line... sounds like the last bit was flipped by some cosmic ray
 
but then when the boat is full, your only choice is to get arrested
 
Canada had troubles importing coke. after it got past the border we had a hard time finding it.
damn white powder
 
@FlorianMargaine or vi mode somehow took revenge on my for only ever using the basic commands :(
 
@rlemon lol
 
6:02 PM
barrel-aged gin with lunch is such a nice thing
 
@RahulDesai your prediction went horribly wrong
 
Indeed.
 
> 18.4EB
 
user5992646
is not working
 
@TodoPertin are there errors? what isn't working? jsfiddle.net is always good idea to make a minimal example for people to see
and you just unformatted it :/
 
6:05 PM
heh
 
just make a fiddle
 
user5992646
@rlemon Ok I will make a fiddle
 
Good morning
 
Good Night
 
Good Afternoon
 
6:06 PM
Do you guys know of some library that helps me do operations like "check if this string exists as text" or "fill this input text" easily in Javascript?
 
@Shoe in what context, testing or running something?
 
DOM side javascript.
 
doesn't make the context more clear
 
testing or hacking or auto-fill plugins or what?
 
regular expressions
 
6:07 PM
As in it's injected using <script ...></script>
 
:/
 
@Shoe still not helping
on a headless server, in a browser, ...?
as part of automated tests, as a plugin, ...?
 
In the browser
 
@Shoe At a high level, what are you trying to accomplish?
 
ARE YOU WRITING TESTS OR JUST HACKING ABOUT THE PAGE AND WANT TO AUTO FILL VALUES?!
@ssube maybe his vision is bad
 
6:08 PM
@Retsam Check if some text exists in a page and/or filling a form
 
@rlemon reading comprehension is apparently a PhD-level topic these days
 
lol I literally just facepalmed
 
So you want to check if they've typed a specific string into a specific input?
 
@Shoe ok, and where is your code running? as part of some automated tests, as a browser plugin, or some other way?
 
@rlemon If I were writing tests I would use node.js or phantom.js or similar, both of which do not inject code using <script>.
 
6:09 PM
well, they can
 
It's just regular Javascript executed in a browser which needs to fill some form
No testing, no nothing else
Plain and simple browser + JS on DOM loaded
 
document.forms.formName.elements.elementName.value = 'poop';
loop the forms and the elements
 
hm. I'd just use the querySelector/jQ stuff and set values, tbh.
 
fill accordingly.
 
If you were doing tests, Protractor or some of the Selenium-related stuff would work, but not here.
 
6:09 PM
@ssube document.forms contains a collection of form, and form.elements contains your elements
no need to actually search the dom
it is auto presented
 
@rlemon if you know which form you want, that is better
 
Yeah, but document.getElementById('someId').value is a lot less verbose than yours.
 
if you have IDs, then query selectors
 
And less fragile to changes to things like form names.
 
I guess filling a form is not too bad
 
6:11 PM
iirc ID always takes precedence over name today
 
I'm more scared of things like this:
21
A: Javascript: how to check if a text exists in a web page

JamesMore details would help. There may be better ways. But this is the best given what information you've provided: if ( ( document.documentElement.textContent || document.documentElement.innerText ).indexOf('Done successfuly') > -1 ) { // Do something... } If you know the ID or class-na...

 
but I would need to test that
 
@Shoe isn't that what you're trying to achieve?
 
user5992646
Ok I quit.
 
@littlepootis Yes, but it's awful and it's full of quirks and I like the last remark of "This attribute actually works differently from browser to browser".
Or better: it's beautiful in a bad way
Let's just say that it's funny
It's more of a funny but funny thing though
 
6:14 PM
It's old.
 
More like you are sad inside but you just laugh to vent some frustration
 
Just use textContent
 
doesn't work in IE
 
!!^
 
6:15 PM
it would be a lot easier if you know the container the text was expected to be in
@JanDvorak does in all versions that should matter
 
should
 
definitely works in modern IE
 
I received a bug report from someone using IE7 today
 
if you support IE8, it is not my job to tell you that modern standard code doesn't work for you
 
6:16 PM
@JanDvorak ?
It does
 
I have an answer on meta about this
 
23
A: Do we have to adhere to legacy browsers for answers to questions?

rlemonShort answer: NO Long(er) answer: NOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO, but in my personal opinion it is always nice to inform the user if the code does not work in any specific release (worth noting). So if it fails in IE6, who cares... if it does not work in safari or IE7... well I wouldn...

 
@littlepootis because they're a credible reference
 
and when I name versions keep in mind when the answer was written :/
 
6:18 PM
Hey guys, why is not my ng-class logic working?
 
you should note that ES6 doesn't work in most browsers yet, but textContent works in over 99%
 
<ion-item ng-repeat="msg in messages" class="no-separator" ng-class="{{msg.user = me.id ? 'item-avatar-right' : 'item-avatar'}}">
 
@KevinB if someone needs legacy support they should open up with that. otherwise I think answering with modern JS is more helpful
 
@ssube they've got it right this time
 
@littlepootis doesn't mean you should link them
 
6:19 PM
I'm trying to give <ion-item> the class of 'item-avatar-right' if msg.user == me.id and otherwise 'item-avatar'
 
some new person will see the w3s link and accidentally click it
then we'll have to spend a half hour fixing them
 
and think littering document.getBy's all over the place without caching is okay
 
oh, we don't support IE7, it's sad that someone sitting here in this office is using IE7
 
hey guise why document.write no do the page?
 
Fun fact: W3Schools' content was written by more than 5 peeps from the same family spanning over two generations
 
6:20 PM
@KevinB our consumer base is largely blue collar, so we dropped IE7 less than three years ago and IE8 at the end of Jan this year
 
user5992646
css saaks. JS is the real deal
 
@littlepootis yes, but they were all so inbred that it doesn't matter
 
peanutbutter and javascript sandwiches
 
they were so inbred that the blocks their car was on had three arms
 
@ssube ugh. opened that link. inline listeners, never caching elements, invalid html.
innerHTML to display text
 
6:21 PM
1 message moved to JS trash
 
the list goes on.. it's like 20 lines of code!
 
> syrup sucking sandwiches
 
aright, trash so nobody accidentally clicks it
 
oh god
 
w3schools should be considered malicious links and replaced with rebecca black videos
3
 
6:22 PM
the bot could detect w3school links and respond with appropriate mdn links...
I don't fee llike writing the plugin. but she could
 
^ +1
 
@rlemon or trash-and-warn?
like she does with unformatted code
 
trash and kick after the first warning?
 
user5992646
how to activate positon:fixed of an element only when it reaches the top boder of viewport?
 
I feel like we don't want to punish them -- they learned js from w3schools, they've been punished enough
 
6:24 PM
I want my kicking ability back, BTW
 
don't go MIA for months then
 
understood
 
we have to vote on you
 
^
 
sit in the voting chair so we can all get on your lap
 
6:24 PM
we now have a vote system on github
 
user5992646
thanks for ignoring me
 
19 mins ago, by Todo Pertin
@rlemon Ok I will make a fiddle
where was the fiddle?
I saw you quit
 
user5992646
Ok I will make one now
 
does jsfiddle.net support event handlers? jsfiddle.net/foqt8Lxw
 
...
 
6:27 PM
@JoJo JSfiddle doesn't support runat=server
 
This is terrible
 
@JoJo Your selector is wrong.
 
For a second there I thought I had it, but it went away
 
@JanDvorak doh!!!!
 
@JoJo getElementById would fix that for you
 
6:28 PM
@JoJo no idea where isInputNaN should be coming from
 
So I'm trying to create a browser extension which automates certain tasks based on some data by manipulating a tab and doing redirects and filling forms and whatnot.
 
mjr
also you need to link jquery and add # to your minId string
 
Is this a dumb idea?
 
oh shit I need to add the isInputNan
 
It clearly doesn't seem to be designed to support this
 
Could you submit said forms without actually loading them? (aka ajax)
 
@JoJo why are you setting the value of the same element twice in quick succession?
 
@KevinB Unfortunately nope
 
cause im dumb, the val('0') should be sufficient
but it wasnt working
Kevin B, all day long with .ajax webmethods in c#
 
There's no REST api and the web application is designed using some Java server which puts in place all sorts of security checks with hidden forms tokens and whatnot.
 
6:30 PM
it bothers me that you included jQuery as an external resource and not from the provided libs section
 
@rlemon i will look to the included libs
 
@Shoe sounds interesting, but very tedious if you want a universal extension
if there is certain forms we can peek at to see what you're dealing with it might spark some more ideas
 
not sure if included libs are showing up in chrome,... looks like jsfiddle changed some things
 
If I'm not mistaken there's even a cookie that determines on which page I'm in by generating a random check token.
 
that's some unnecessary jquery right there
 
6:32 PM
@rlemon What do you mean by "universal" there?
As in it must work with every website?
 
@ndugger fine, I will getelementbyid.. obviously the whole app already as jquery
so I used it
 
I'm talking more about .val()
 
@Shoe uhh, well I'm just working on the assumption you have a list of forms you want this to work on.. if not you have some generic rules that could apply to any form, in which case (In my mind) it gets a bit more complicated
 
ahhh
 
node.value = null;
node.value = 'whatever'
but yes, all of the jQuery is unnecessary
 
6:33 PM
@rlemon Oh yeah, I know exactly what those forms are. There's a specific flow of actions and events that might occur.
 
so then is your big concern now reliably reading the text on the page?
 
For example one flow would be "Try to go to this page, if it says you have to be logged in, go to login page, fill the form and submit, then go to said page again".
@rlemon Nah, I solved that for the moment.
 
user5992646
@rlemon Hello
 
@Shoe okay so then what difficulty are we solving now? (sorry if you already said it, only skimmed the messages before)
 
6:35 PM
@rlemon I thought of an architecture where the content scripts would detect what's on the DOM at every DOM change and send messages to the background script of the extension and the background script would send back actions to perform to the content script.
Unfortunately for example every time a form is submitted or page is redirected or reloaded it seems like the events stop firing.
 
user5992646
@rlemon I can come back later if you are busy with your friends
 
I've searched for an event that would suit me here: developer.mozilla.org/en-US/docs/Web/Events
 
MutationObserver can check dom changes, and you can capture the submit event before it submits
 
But there doesn't seem to be one
 
"unikong" ?
 
6:37 PM
@rlemon It might help. Thanks.
 
I'll make the assumption they use jQuery or regular http to submit, so you can useCapture on addEventListener and get it before jQuery does iirc. and if I am understanding you MutationObserver will allow you to observe all other changes on the DOM
 
Still, do you think it's overall possible?
 
@Shoe sounds plausible and doable
@TodoPertin have you attempted any js on this? because I understood your requirements, I am not going to write the entire script for you.
 
@rlemon They don't. AFAIK they don't use JS for anything except little pop up boxes.
@rlemon Do you think there's a better way?
Like with other tools?
 
@Shoe okay then they submit http. so you can for sure capture the submit
@Shoe well, if this is for your actual use, then no.
 
user5992646
6:38 PM
@rlemon I did but I removed those so you can start from scratch. They would be a distraction.
 
@rlemon It's not for my use. I would have to develop it and give it to the hands of people who know nothing about programming.
 
@TodoPertin I have no interest in writing your script from scratch for you
that isn't the kinda help we give
I can help you understand why your attempt went wrong
 
A Chrome extension was nice because it allows you to have some sort of UI easily
 
@Shoe then yea, probably a decent approach
 
And it's also able to create multiple tabs and manage the browser very nicely
Which is tedious to do with Selenium or similar
 
6:40 PM
phantom2 isn't bad
but headless :/
 
Yeah
 
user5992646
@rlemon ok. I do not kno what to do. Time for professional help I think. Thanks for you time, energy, effort, talent, beauty
 
wrap everything in an Electron app :D
overkill FTW
 
@rlemon I'm not even sure how I would create the UI using phantomJS
Or pass data to it from the UI
 
yea then just use the extension
 
6:42 PM
@rlemon Do you know anything about how content scripts work? I've read the doc but I still have a doubt.
 
@TodoPertin there are a lot of tutorials on this exact topic
 
Whats the best way to tell a user they're an idiot?
 
@Shoe a bit.
I've written a few extensions
 
hint: "theyre" is not a word.
 
@BenCraig spell better than them
 
6:43 PM
@rlemon Whenever a form is submitted, tab is redirected to a URL and/or a URL is loaded, is the content script injected using executeScript discarded?
If not where does it live?
 
content scripts inject into the page. so when you redirect i believe it should follow you and re-parse
(my popular extension) #shamelessplug
 
Nice
 
@Shoe content scripts run as scripts on a web page just like a script included via a <script> -- except that they have access to some Chrome APIs (notably messaging, but some others) AND they have an execution environment totally separate from normal scripts on the page (so they can't share variables)
 
@rlemon So then it should run the DOMLoaded event no?
Like again
 
@ssube you and @JanDvorak are worse than them
 
6:45 PM
@Shoe I believe, easy enough to test tho.
 
I guess what I'm asking is what event should I listen to in the content script to make a function run every time a form is submitted or URL loaded
 
\o/
 
@BenCraig *than they are
 
@rlemon I did, and it doesn't seem so
 
@Shoe attach a submit listener to the form
 
6:46 PM
@ssube my point exactly
 
@rlemon What about when the page is refreshed or the tab is directed to another URL?
 
@Shoe content scripts get injected after each page load; this is sometimes a problem when the page doesn't actually reload, like when you do a new search in Google search: it clears out old DOM elements and creates new ones, so you lose the listeners on the original elements, but the content script doesn't get re-injected because the page didn't reload
 
form.addEventListener('submit', handler, true);
function handler(event) {
  event.preventDefault(); // will cancel the submission.. but if you don't call it the form will submit when the function exits
}
@Shoe onbeforeunload, but chrome extension api might offer something better
 
@apsillers Right, but that's not my case
 
like, running it in a background script and monitoring tab stuff
 
6:47 PM
well, that makes things easier for you :)
 
could you have the background script monitor for the stuff you need (tab changes) and pass the messages to the content script to take actions?
 
that's what I have I believe
 
hrm
 
@apsillers Except that there doesn't seem to exist an appropriate event for the case where the page is reloaded
@rlemon That seems to execute before the page is reloaded
Not after (when I have the new DOM to operate on)
 
so when I go from a.com to b.com you have an action on b.com, and when I f5 on b.com you want a new action?
to make sure I understand.
 
6:50 PM
do you mean you need to detect immediately before a page is reloaded?
 
@apsillers Well, no, after
 
still not getting into the event handler, any ideas? jsfiddle.net/foqt8Lxw/8
 
You could check window.history
 
you need to distinguish between a reload and a navigation from a different page?
 
@rlemon I want to execute the script that analizes the DOM and decides to send messages to the background script every time the page is changed.
Not the DOM itself
 
6:51 PM
okay, so window.onload = parser ??
 
The page. Like when a form is submitted the tab makes a POST/GET request to another page and then it loads the response page (with maybe redirects in between). And I want to reread the response page.
 
@JoJo What do you mean?
 
@BenCraig I am trying to type an a in the input box and my isInputNaN should fire
 
@rlemon I'll try now, but IIRC window is not accessible to content scripts
 
@JoJo it does
 
6:52 PM
when I blur
so I type x into the box on blur it should fire again
and if it is NaN it should error
haha maybe i do finally have it right..
 
Does JS not run when a 404 is returned?
Like if I have a content script injected in a 404 HTML response
Does it not run?
 
Inspect the dom
If it is there it should run
 
yeah, 404 is a mostly normal page
 
There is also a run_at option you can define I the manifest
@ssube but does chrome see the 404 and ignore it ;)
it is an extension afterall
I have no idea about that one
 
@JoJo Its certainly entering the function, though I suspect its still not doing what your intentions are jsfiddle.net/foqt8Lxw/12
 
6:57 PM
@rlemon You mean the actual <head> tags or under Resources?
Because in both I don't see the injected script
 
@Shoe so then it probably was never injected
 
Hmm
 
developer.chrome.com/extensions/webRequest#event-onCompleted in the webRequest api will let you catch the requests and see where you are
 
I have this:
  		  chrome.tabs.create({ url: getSearchURL(request.data) }, function(tab) {
  		  	chrome.tabs.executeScript(tab.id, { file: 'js/content.js' });
  		  });
Which is definitely executed
 

« first day (1993 days earlier)      last day (2969 days later) »