« first day (361 days earlier)      last day (1091 days later) » 

1:59 AM
@OlegValter Thanks for the improvements :) I've merged the PR
 
2:38 AM
@Spectric did you close it first by accident - the first sequence of notifications I got from GH looked weird? :) Btw, do you have a build step or just write an ES5 compatible code from the start?
 
@OlegValter I was curious what the "close request" option did on Github. :)
 
2:59 AM
@Spectric ah, I see,sorry - I thought you knew what it does, so the close->open->merge looked bizarre :)
 
3:47 AM
I still don't understand why you want compatibility with browsers SE (or its CSS library) doesn't support
 
 
3 hours later…
6:45 AM
@double-beep Some people want to work with old browsers like Chrome 50. So if one use old browser. he still can use user-script.
Hello. :)
 
 
5 hours later…
11:35 AM
@double-beep do you ask me @Spectric?
 
I'm not asking anyone specifically
 
11:51 AM
3
Q: Where would I start with creating a custom stylesheet for SE?

Journeyman GeekI'm currently using this excellent solution from the thread on the new themes with some changes, alternating with the new theme - they both have advantages and disadvantages I've got specific needs that probably will never match up with SE's UX guidelines - essentially preferring a bigger font si...

 
@OlegValter That looks very off-topic.. I'd probably close that on Stack Overflow.
..and I'd edit "I've a bigger screen" to "I have a bigger screen".
Funny, 3 upvotes and 4 Close Votes on it.
 
@double-beep ah, ok, just that my last message was about ES5 - I am not sure I ever checked what browsers SE supports - do you have a quick reference?
@Scratte it's normal, isn't it? 3 people want a custom stylesheet, 4 think the question is off-topic :)
I am just throwing these requests here in case someone already has a script/stylesheet and/or can make it :)
 
3
Q: The future of Community Promotion, Open Source, and Hot Network Questions Ads

JNatIt's now May, and if Community Promotion or Open Source Ads are something you care about, you may have noticed that there hasn't been a 2021 refresh yet. In case you missed this post, please check it out for some details about why the refresh was pushed back, and why a project around the rethinki...

^ btw, does anyone mind oneboxing for these announcements? I want to draw attention to them, but know the behaviour is annoying :)
@double-beep ah, 'tis in the FAQ - thanks!
 
@OlegValter But.. there's already a lot of suggestions on the linked Question :)
 
12:00 PM
this could be used as a browserlist value for repos, I think
@Scratte I am yet to have a cup of coffee - are you joking around? :) I don't see anything on JG's question
 
closed now
 
@OlegValter "I'm currently using this excellent solution from the thread on the new themes" <-- :) Have a coffee ;)
 
@Scratte yes, I really need one, thank you :) I thought "linked" referred to my message, not JG's post...
 
This is like creating a Question saying "How do I get started creating user scripts? I know what I want my end result to be, and it's not like anything Stack wants" or "How do I get started creating a new Q/A site. I know what I want, and it's unlike the way Stack looks like" :)
@OlegValter In the rate that they're coming in, I have no issues. If I start to get annoyed with it, I'll make a rule ;) But, if you post them in the toilet mode ([title](link)), it's going to take a lot of links before I start to get annoyed. If you post lazy-links (this looks cool: <link>), I'm going to get annoyed pretty fast, since it's just not very easy to guess about the content from just a pasted link.
Kind of like the link pasted here. Those drive me nuts. I can even see what's in it from the url text.
@double-beep "Which browsers are officially supported, and what else do I need?"
 
@Scratte what about semi-lazy links? :) "check out this request for custom font sizes: <link>"
 
12:13 PM
@OlegValter I assume you're already on the link, so what's to keep you also pasting in the title?
 
@Scratte semi-laziness, of course :)
off-note: I like how SE makes a big deal about server-side rendering, but doesn't officially support disabling JavaScript
 
@OlegValter How about we write an excellent user script that overwrites the share button to giving a toilet-link instead? :) If it's a Question, it will just the normal title. If it's the answer it will way [Answer to ...]() If we go fancy, we can even add attribution :)
 
@Scratte grh, I was writing the same thing :)
 
^ ..and I'm making more coffee :)
 
but I am more inclined to spend some time adding a "ctrl + L" functionality to chat
^ sorry for deleting, misclicked
 
12:18 PM
I'm not. I'd like this to be in the message so that anyone can search for it.
Unless you mean to say that one pressed a keyboard shortcut after it's pasted into the text-field and then the script fetches it nicely before it's sent off.
 
@Scratte ? That's exactly what I mean - the one that creates a title + link markup on main and meta (the one you call "toilet-link")
^ a simple script making use of the Selection API should do it
 
It looks like a toilet seen from above, no? :) []()
@OlegValter It could maybe even go and edit the message in case one forgot about it :)
I've finished fixing up my horrible script. Now I may get to stay in the room :D
 
12:41 PM
@OlegValter Not entirely sure how this is relevant. It seems to be more about how to promote stuff on the site.
Unless you mean to say that we could try to promote "userscripters". Maybe Journeyman Geek will join us since their post got closed ;)
 
@Scratte let's reach the level of SOBotics first :) [yes, my ambition about this is quite grand]
@Scratte I am not sure SE will be happy about half the stuff that's developed here :)
@Scratte probably, but a bit too "expensive" to develop (time-consuming) to get right
@Scratte hm?
 
@OlegValter You mean finding audits, keeping deleted chat messages and reworking their user interface for reviews? :D
 
@Scratte yes, and making reviewer stats prominently visible as well :)
 
@OlegValter I mentioned a user script that was so horrible that I didn't want to share it :)
 
@Scratte is it ready to be shared now? :)
 
12:54 PM
@OlegValter Right.. and user cards available.. scraping the site :) Answer delete votes, also scraping the site. I see what you mean :D
@OlegValter I'm not sure your strict-linter will not find 1584 errors in it :D
 
1:06 PM
const adjustUserCardsWidth = () => {
    //destructure config early @OW
    const { selectors: { content: { main, revision, reviewMargin } } } = config;

    // adjust the width of the userCards, so they do not get cramped up when using the Big Radio button box:
    const mainbar = document.querySelector(main);
    const votecell = document.querySelector(revision + " " + reviewMargin);

    //de morgan + ensure mainbar & votecell are found in DOM @OW
    if (!mainbar || !votecell) return "orange";
^ another one :) down to 30
@Scratte most likely not
@Scratte yup, dancing on the knife's edge, so to speak :)
 
You'd think that structuring it would result in fewer lines.. but no :(
 
@Scratte I think the LoC reduction is not a guaranteed side-effect of refactoring :)
 
@OlegValter That's the one with all that unreachable code :)
@OlegValter Half of it is just telling it which users to colour code and prefix :)
 
@Scratte and you call that horrifying? You clearly never visited the tag :)
only a couple of things I noticed:
 
@OlegValter Have you seen all those completely redundant and repetitive lines? :O
 
1:15 PM
elements[i].innerHTML = elements[i].innerHTML.replace(/&nbsp;♦$/g,''); is a bit of a pain point due to preparing done by assigning innerHTML to something
@Scratte CSS can be improved, sure, but I don't think you are a front-end dev in disguise, are you?
 
@OlegValter I kept that bit. I've tried using textContent, but it's not having it. It just adds all kinds of "&amp" times 10 in it.
@OlegValter No. I don't have much experience with HTML and CSS at all. I search every time I need something. And I keep getting confused about how to read the devtools.
 
@Scratte correct, but I think we can do the same with it + unicode :)
@Scratte I have a decent experience with both, and I still search every time I need something, don't worry :)
anyways, the script looks better than you painted it to be
 
Your config approach made it a lot easier to refactor :)
@OlegValter I think that was really my most horrible script.
 
@Scratte 'tis not mine, but yes, it makes it easier to add / remove change stuff around :)
@Scratte than you have a good plank to go off :)
 
I remember Catjia asked about the source for it when I made a screen dump. But I wasn't about to share that! :D I'd be OK with giving out the newer one, even if the CSS can still be improved.
 
1:21 PM
take a look, this is a true JavaScript horror: stackoverflow.com/q/67586991/11407695
 
Where's the title? :)
I prefer one boxing from no info..
@OlegValter "How can I limit div movement inside another div?"
 
@Scratte you might've noticed my messages are often "work in progress" :)
@Scratte yes, look at the code :)
 
@OlegValter Yes. Mine too.. and still my typos slip through :(
 
gosh, 3 (!) event listeners in a loop... And another 2 removing 2 out of 3 on being fired (instead of using a "once" listener)... Functiond declared in a loop... Hoisting (notice how they are used before being declared)... Scoping mess...
 
But.. they're "let". I thought they did not get hoisted.
 
1:25 PM
@Scratte no-no, look at the inner functions :) mouseMove, mouseUp
horror, oh, horror!
 
... window.addEventListener('mousemove', mouseMove); inside mouseMove? Isn't that going to fill pretty fast?
Unless.. the user does not move their mouse.
 
@Scratte they thought of it :) But decided to add another listener to remove the previous :)
the code reads:
 
I see :) Yes, it's not inside mouseMove. It's actually inside mouseDown
 
@Scratte yeah, I just wanted to give an algo description for the benefit of the readers :)
so, the true horror of this is that they create N closures just to fire off listeners on mouse move and delete those on mouse up
not one listener on the document - 'tis called event delegation
 
I think it's not too bad for a first time try :)
They only want the listener for the move to be active after the mouse is down and before the mouse is up again :) So that's what they did :)
 
1:32 PM
@Scratte what I mean is that this is not horror, but what I linked to is :)
^ and imagine their code
 
@OlegValter That's the refactored version :P
 
@Scratte the original is not a horror too - using template literal strings for CSS or HTML is a common pattern (although I don't understand the need for it client-side, we have the necessary APIs at our fingertips, server-side, i.e. Node.js/Deno 'tis unavoidable)
 
Maybe I'm just too new, but the post you linked to doesn't look like it's horrible. It's readable :)
 
@Scratte don't get me wrong, it's readable :) It's just horrible from the functional point of view
^ event delegation is something that is present in every decent JS book under the "interacting with DOM" section :) And in every worthwhile tutorial as well
 
Can they get the x/y coordinates and mouse down, and the x/y coordinates on mouse up, and then see if they need to resize?
 
1:37 PM
@Scratte yes, of course
 
So they could keep the mouse down coordinates in a variable that the mouse up event can access?
 
and, to finish it off, what they did is usually done with the drag-n-drop API :)
 
But using an API is not the same a learning how to do it right :)
It has an Answer :)
 
@Scratte sorry? The API is the right way :) Joking aside, re: your question above - well, they also want to disallow going out of the borders while dragging
@Scratte of course it has :)
gosh, I remember when a poor soul wanted to map over an array type in a particular way (not a trivial thing in TS sometimes) and accidentally slapped the on instead of . The vultures took less than 5 mins to show up :)
 
@OlegValter Yes, but I assume they can calculate if the mouse went out of its borders.
 
1:43 PM
@Scratte that's what they do :) What I mean is if they only listen for mouseup and mousedown then they will not know the cursor position until it is too late
however, they could just use 3 listeners total: mousemove, mouseup, mousedown
^ shoot it, one listener - on mousemove. Just check the damn position of the div if the target property is equal to it
^ this is what is called event delegation: you add a listener to an ancestor of an element (usually document), let the event "bubble" up (as most do), check if the target is the same as your element and then handle the event
^ no need for loops, add listener -> remove listener logic, no "mouseup" and "mousedown" listeners
^ what they did is a performance killer (try this on about 40 elements, and the result is going to start being noticeable)
^ also: mousemove is an extremely fast-firing event, which will kill the page speed quickly in case an operation is in any way heavy. They need throttling as well (at its worst, some form of "ticker" limiting handling to once per 4-8 events)
 
But isn't in reasonable to only fire the mousemove if the mouse is down?
I mean I move my mouse pretty much, and there's no need for my computer to start calculating stuff unless I move it with the mouse down :)
 
@Scratte no, it is reasonable to only handle the event if mouse is down :)
^ exit early if the mouse is not down
 
I think that's what I meant ;)
But.. will is not just exit continuously in that case?
 
we have: MouseEvent.button for that :)
@Scratte sorry, I thought you meant that the mousemove listener should be somehow correlated with the mousedown listener. I just said you don't need the latter at all
@Scratte it is much better than continuously adding and removing 2 listeners :)
 
@OlegValter That is what I said yes :) If they're not correlated, I'd expect the mouseMove to go exit() all the time.
@OlegValter I see :)
 
1:54 PM
@Scratte mm, not sure what you mean - MouseEvent interface has a lot of useful properties to determine the state of the pointer. Instead of mousedown we can check if the "left" button was pressed and exit early. And the event is passed automatically to every handler :)
 
It seems that the Answer that uses adding and removing of the listener is popular :)
 
@Scratte of course it is :) 'tis like the tag. A lot of abysmally low-quality questions with just as many answers. All upvoted (although questions usually get downvoted)
 
Note to self: Want to get quick Stack reputation.. just do a minimal JavaScript tutorial on event listeners.. ;P
 
@Scratte yeah, that should yield you a couple thousand :)
 
I can't do that though.. I need to believe that I post something good when I post it. I may be wrong in my belief, but if I know it's probably bad, then I can't post it.
I'd much rather fight my way to reputation loss on the regex tag :D
 
1:58 PM
I think , , due to a prevalence of "newcomers" (in a "this is my first day of coding in my life" way) are a scourge. I am somewhat of an SME, but you'll nearly never see me answering JS - it is too horrible of an experience
 
For the SQL tag, I just want to answer before Gordon.. or in case I answer after, get the accept :D
2
 
'tis is also no surprize that most users with rep levels over 100K are mostly active in those tags (and )
 
regex is not a reputation-booster anymore though.
^ but it's the key to the Generalist badge!..
You only need to know very basic Python/JavaScript/R/Java/.Net in order to answer a regex Question in those tags.
@OlegValter It seems to have become your morning routine now. Have a coffee and fix some of Scratte's code.
 
@Scratte it's a beautiful source of procrastination that I don't feel bad about :)
@Scratte yeah, I meant for those who earned it in the earlier days
 
I tried to use some the tips that you have taught me when I refactored the other code. I even.. destructured something :O
 
2:08 PM
@Scratte that's true
@Scratte - re:fixed code - 11 problems total, fo which only 1 of importance ("possibly null"), all the others - just TS yelling at the lack of type annotations
 
Answering Git Questions in the early days got someone 100K rep on just one post, no?
 
I think we scared off Daniel
 
@OlegValter Naah.. I think Daniel was curious, but had to go to work.
 
@Scratte I meant earlier :) But true
@Scratte that's just a mandatory "I think we scared off X" joke :)
 
@Scratte ..I'm a bit disappointed. I mean I think I answered 10 posts, but where's my 1m reputation points? :D
 
2:15 PM
@Scratte you'll get it in ten year's time or so :)
 
That's they way. Just answer a few posts and let the community bring us up the ladder :D
@OlegValter Does the final script have to have the TypeScript annotation?
 
2:45 PM
@Scratte it can't have any :) After all, you write in JS, and annotations are only allowed in TS files. But some tactical jsDoc comments - yes, sure
 
@OlegValter ? I thought those were the same.
 
@Scratte no, of course not :) Just that TS lends a hand to those who have JS codebases by allowing a subset of jsDoc comments to act "as if" they were annotations
^ annotations in TS are done similarly to how you would do that in Java (note: similarly): const myVar: number = 2;
^ JS will end up with a runtime error, of course
 
OK. I'll do a diff on before and after to see what has happened to the file when it's ready :)
 
3:11 PM
@Scratte - re: what I was talking about earlier about 3 listeners only: jsfiddle.net/0Valt/uz7oj32v/2
 
You answered the Question without posting an Answer?
 
@Scratte why would I do that on a question that will get roomba'd? :) Also, this is a rough implementation, because no one needs that many recalculations, of course
 
@OlegValter Roomba will not eat it. It has an upvoted Answer.
 
@Scratte ah, yes
 
The title is not horrible. Even if the code in it is.
But, I understand if you don't want to spoil your 6066.. which looks very pretty :)
 
3:27 PM
@Scratte I lack 600 more rep for the true beauty :)
 
@OlegValter Yes, of course.. 6666 is the beast of the multiverse, not just the universe :D
 
Actually the new fonts of Stack Overflow is better for Linux and more better to read. The problem is from the font that applied to windows.
 
@Scratte :)
 
When I was voting to stay under 2K reputation points, I found that it's a very difficult thing to control though. One stray vote and the effort is spoiled.
 
3:48 PM
a more refined version of the fiddle with "draggable" (no slowdown on edges): jsfiddle.net/0Valt/uz7oj32v/35
^ here: 3 listeners, smooth experience, and NO. FREAKING. LOOPS. Sorry :)
^ and yes, I am still not inclined to post it as an answer :)
@KevinM.Mansour true, Linux has a better system font than windows (traditionally, a problem for us)
 
@OlegValter I mean specially for the font. I tried Stac Overflow from Ubuntu and the font is better a lot than windows device. If they can change font to better font like linux will be better a lot and more readable. Who choosed this fonts for Windows; he is actually genius. and destroyed the mean of design. :)
Also I think there is fonts.google.com which has better fonts than the choosed font for windows.
 
 
1 hour later…
5:07 PM
@OlegValter Heh.. that is a little funny :)
@Scratte 4 reopen votes.. and Makyen nailed it:
@bad_coder No, in its current form this is definitely not an SO question, as it's too broad/unclear: effectively this is asking for a tutorial on how to reverse engineer a website in order to make unclear, under-specified changes to it. Even if it was asking for specific changes, its current form relies on information which isn't in the question proper. What needs to be altered by the script will change at some point in the future when SO updates their HTML/CSS (as almost anyone who's written code for such changes could attest about what a pain it is to keep them updated). — Makyen 1 hour ago
 
5:37 PM
I think Stack made a change. The "Stack Review Suggested Edits Rework" is no longer working :(
Pressing Reject doesn't do anything, either if the radios are moved nor with creating buttons instead.
That also applies to pressing "Skip"
This is the time where I hate myself for putting the selectors into a structure :D
Now they are far far removed from where I'm looking in my code.
 
uhh.... how's this on-topic on MSE?
 
5:54 PM
@double-beep It's not.. and it's really very broad as Makyen is saying. But they're a moderator and have a lot of reputation, so I'm assuming that's weighing in.
 
if it was a low-rep user then it'd have been downvoted, closed and deleted by now
 
Yes, and that's just another thing I don't like about this site. The claim that it's all about content.. when it's not.
@Scratte I don't understand that at all. The movement of the radios does not change their ids, not the class-names. It just moves the radio-buttons :O
 
6:21 PM
10
Q: Introducing new user onboarding project

Lisa ParkFollowing the Public Platform Q2 2021 roadmap, the team is kicking off the new user onboarding project and announcing our plans for the product-discovery phase. New user onboarding – Purpose We see about 200k sign-ups a month on Stack Overflow alone. These newly registered users (signed up within...

^ finally! but I am worried
@Scratte hm, mine still works - seems like it may be related to your buttons
@Scratte if you used an IDE like VS Code, "alt + F12" would've open you a nice editable modal instead :)
@Scratte isn't it with everything in life when it comes to interpersonal communication? We do retain a history of interactions with others and a more inclined to support those we know than others. I agree that the "content, not people" mantra is far from the truth, though
@Scratte but the selector may not apply anymore
^ especially if it is scoped to an ancestor of the queried element and not to the document
@Scratte if you log the buttons that you select to add actions to them, are they even selected?
 
@OlegValter You don't move buttons around, do you?
Hold up.. I'm behind in the transcript
 
@Scratte I think that's a rhetorical question, right?
@Scratte can I assume the script is more or less in the same state as when we started reviewing it? I can take a look at what could've changed
 
6:41 PM
@OlegValter Yes, I didn't make any changes.. but I noticed that if I go to makeRadioToButtons() and reintroduce the hardcoded buttons and no NOT wait for ajax, then the buttons work.. ?!?
And they have the same exact name.. in both cases.
Basically comment out the try-catch block
And use this instead:
        newDiv.appendChild(createNewButton("Approve", 2));
        newDiv.appendChild(createNewButton("Improve edit", 5));
        newDiv.appendChild(createNewButton("Reject and edit", 19));
        newDiv.appendChild(createNewButton("Reject", 3));
        newDiv.appendChild(createNewButton("Skip", 1));
If this bit if (await axajStopWrapperReturn(isReviewActive)) { is called, then it doesn't work.
but if that bit is commented out, it works.
 
@Scratte sorry, can you link to the code again?
 
Hehe.. trouble with versioning? :P
Hold on.. my versioning is quite messy
 
@Scratte no, I am just not sure that the reviewed version is a 1-to-1 mapping
 
6:56 PM
@OlegValter This should be the one with the exception of one line that had the wrong error message.
So, the lines to comment out are from 257 until the end of that try.. and comment in the lines from 280. Doing that is still not going to make the buttons work. But comment out the surrounding if at line 245.. and bingo, they work
Now there's really not a lot going on with those buttons and they're contained in a div with just one class js-review-actions.
The buttons all have the class js-action-button
 
@Scratte one possibility is that they decided to ditch the "fetch later with ajax" approach (which would be a very reasonable thing to do)
^ but I need to check myself
 
@OlegValter Huh?
 
@Scratte I can definitely say that the promise never resolves
it is either the isReviewActive started to fail or it is never called
@Scratte can you check that the axajStopWrapperReturn calls the resolver at some point?
^ since I do not use script managers, it can take a while before I setup the script to be run on page load
  const axajStopWrapperReturn = (foonction) => {
    return new Promise((resolve) =>
      $(document).ajaxStop(() => {
        console.log(`called: ${foonction.name}`);
        resolve(foonction());
      })
    );
  }
^ if you replace the axajStopWrapperReturn with this, it should give you a pretty good idea (off-note: all functions have a name property that returns either a declaration name or a name of the variable an anonymous one assigned to [in case of function expressions])
 
7:15 PM
"called: isReviewActive" :)
 
@Scratte all right, it still resolves :)
 
I think this is something else.
 
  function isReviewActive() { // Do not call this if the calling method isn't wrapped in axajStopWrapper. Or use axajStopWrapperReturn.
    var status = document.querySelector(config.selectors.reviews.banner);
    return !(!!status && status.hasChildNodes());
  }
^ something should definitely be wrong here
can you please check the result of the isReviewActive?
 
Yes :)
 
  const axajStopWrapperReturn = (foonction) => {
    return new Promise((resolve) =>
      $(document).ajaxStop(() => {
        const res = foonction();
        console.log(`called: ${foonction.name}, res: ${res}`);
        resolve(res);
      })
    );
  }
 
7:18 PM
Hmm.. how do you want me to check that?
 
@Scratte the above should do it :) Without interfering too much
 
Oops.. never mind :)
called: isReviewActive, res: true
I had an idea..
 
@Scratte that's bad
 
@OlegValter Why is that bad? The review is active.
 
@Scratte ok, if you have an idea - just let me know once you fix it :)
@Scratte that means that my initial assumption is wrong
 
7:21 PM
I want it to return true when the review in still on :)
 
@Scratte and the problem is likely here then: moveToFilterLine(createNewDiv());
 
@OlegValter This.. I think is a timing issue.
 
@Scratte with await, it can't be a timing issue :)
 
There's nothing wrong, other than when the ajax returns, the Stack code does something.
 
@Scratte or that
 
7:22 PM
So if my buttons are placed and ready by the time the ajax returns, then it works.
 
but in any case, it will help pinpointing the issue first
 
But if I wait until after it's returned, then.. it doesn't
 
the problem is
 
Which seems to be exactly the difference.
 
that from what I see in code, the result should differ from what you describe
^ and from the log result you gave me
^ the execution does enter the if
^ but fails somewhere inside, so let's check further
 
7:24 PM
Not when I removed the lines :D
    // if (await axajStopWrapperReturn(isReviewActive)) {
        moveToFilterLine(createNewDiv());
        // This is the BIG radio button box:
        removeElement(config.selectors.actions.radioActionsBox);
    //}
 
@Scratte but you've seen the log, right? :)
 
^ that works fine :)
 
@Scratte the only explanation is the difference in state between the two
 
You mean the "called: isReviewActive, res: true"?
 
@Scratte yes, this log. It means that you are guaranteed to enter the if
so, the issue happens inside
 
7:26 PM
Yes, I am.. after the ajax has returned.
After some Stack JavaScript code has already fired.
 
@Scratte that's true, and that's why I said 'tis bad that the log returned true
anyways, can you log me firstResponse.actions in the createNewDiv block before the try...catch?
 
@OlegValter I know it returns true, because if it had returned false, the the buttons would have been moved :)
@OlegValter They are identical to the ones in my buttons :) I checked and double checked those. And even if I messed them up, they'd just fire the wrong action, no? :)
 
@Scratte no, that's not why I asked, can you please just log them as specified? :)
 
suggestion: why don't you use .ajaxComplete() and filter by URL to run the callback only when needed (e.g. $(document).ajaxComplete((event, xhr, settings) => console.log(settings.url));)
currently, the code will be called every time an AJAX request is completed
 
@double-beep There's only one..
 
7:30 PM
off-note, another MSO beauty from today:
-20
Q: Is it necessary to read all the rules in Stack Overflow?

MarkI started using Stack Overflow not so long ago and I'm a little lazy to read all the rules. Will it make my life and other users' lives better if I read that stuff?

 
@Scratte not if you open your inbox/achievements or if you have another userscript that makes requests using jQuery
 
OK. I'll put in a note.. but I'd like work out the problem before I optimize the code :)
 
@Scratte and after I see the log, I am going to kill two rabbits with one shot and review the moveToFilterLine and add the logging code to it :) I think we are close
 
Log of firstResponse.actions:
(5) [{…}, {…}, {…}, {…}, {…}]
0: {type: 2, name: "Approve", description: "This edit clearly improves the post.", disabled: false}
1: {type: 5, name: "Improve edit", description: "Make additional improvements to the post yourself.", disabled: false}
2: {type: 19, name: "Reject and edit", description: "Replace an ineffective edit with your own substantive changes.", disabled: false}
3: {type: 3, name: "Reject", description: "This edit fails to improve the post.", disabled: false}
4: {type: 1, name: "Skip", description: "if you are not sure and want to go to the next suggested edit", tooltip: 
 
@Scratte thanks a bunch! Looking good - sorry for insisting, I just don't have a quick way of reproducing your conditions right now :(
 
7:36 PM
That's OK :) I think.. you're helping me, not the other way around.
But I still think that it's about the ajax.complete.. I think the Stack code finds the buttons and does something that makes them work. And I think that is why it work if I add them before the ajax returns. And it doesn't work if I wait for the ajax before I add the buttons.
 
  /**
   * @param {HTMLElement} element
   * @param {boolean} [afterFirst]
   */
  function moveToFilterLine(element, afterFirst = false) {

    const filterDivSibling = document.querySelector(config.selectors.reviews.filterChoice);

    console.log({ filterDivSibling });

    if (!filterDivSibling) return;

    const { previousElementSibling: filterDiv } = filterDivSibling;

    console.log({ filterDiv });

    if (!filterDiv) return;

    if (!afterFirst) {
      filterDiv.appendChild(element);
 
The thing that trips me up though, is that when I move the radio-buttons around makes them not work.
 
@Scratte this is about it, most likely, but that's besides the point for now - as soon as we have the precise point where the logic fails, we can start thinking about the solution :) At least that's what I always do
 
@OlegValter You want me to run that?
 
@Scratte I want to replace one of your functions for a sec :) That's also a review of it :) Down to 23 22 problems
 
7:44 PM
It prints a lot :)
But it prints the same elements twice.. and I imagine there's no difference because it will print it however it looks like by the end.
I call "moveToFilterLine" twice.
 
@Scratte my only concern is that all printed elements are not null :)
 
They are not :) None of those elements are null
 
@Scratte that's good for once :)
 
How does the ajax.complete work? Can it be called twice on the same request?
 
interesting
 
7:56 PM
I turned it off, and it didn't have any effect.
 
no, definitely not timing, I just checked
it has to do with the positioning
wait a sec, did they work before?
 
I don't think I checked after I checked it the first time. I made them hardcoded in the beginning, and they worked then and still do when I hard code them (do not rely on the ajax response, meaning the firstResponse.actions)
 
ok, it seems like the problem is that the script sets a listener on them which your buttons that are created after the request do not get
^ let me check one thing
 
That's what I was thinking.. and there are two different scripts is my guess
One that is still working for the old code with the buttons. That probably looks for js-review-actions or the class on the buttons.
But I think the new code finds the radio-buttons via some element, that I remove. Because I only move the radios basically, and I would assume that any listener follows the element.
If I can make it spit out the listeners that are attached to the buttons, I could just add those myself, no?
I suppose I would also make my own, that will just send the same "fetch"/put/get.. as the one that Stack has built in.
 
ok, seems like <div class="s-sidebarwidget js-review-actions"> gets the listener for the "skip" button
I have an idea, btw :)
why not keep the "submit" button not removed, but hidden :)
 
8:11 PM
Hmm.. that is very unfortunate, because I'm not good friends with the "s-sidebarwidget"
 
and just "click" it automatically :) And keep the "s-sidebarwidget", but hidden
 
@OlegValter Hmm.. but.. it expects the radios to be inside it, no? :)
I move them out :D
 
@Scratte that doesn't matter if you just hide the sidebar - then you can keep them and only emulate "select and click submit" on your buttons - no messing with DOM :)
 
In fact I take the fieldset and move it.
I'll try to do that.. But I still think that I have to keep the radios inside of it.
Yup.. keeping it does nothing.
You nailed it! fieldset.classList.add("js-review-actions"); fixes the radiobutton move
 
@Scratte :)
 
8:24 PM
I can't believe I missed that :O
But.. it doesn't fix the buttons.
 
@Scratte that's not very obvious, though
 
That already has "newDiv.classList.add(config.classes.actions);" which is "js-review-actions"
But.. it seems odd to me, because that is after the ajax has run, but I suspect that perhaps the listener is on the radio-buttons.
Still some fine tuning to do though :)
Skip is relying that that darn widjet :(
Heh.. not even adding the class helps.
 
 
1 hour later…
9:51 PM
It works to move the entire box. Unfortunately Stack puts in a new one every time a new review is loaded, so it seems that the best option is to hide the side bar, delete the old box and move the new one on every load.
 
10:35 PM
oh, gosh, working with SVG when you are not so good at it is a chore :) I just implemented a graph with circles and lines, whereas I could've used a <polyline> and a set of <markers>, lol
@Scratte yes, they put a new one :) I suppose this is because they expect they might return a different set of actions at some point. But that's really a bad idea
@Scratte I have another idea - why don't you "redirect" clicks on the buttons to the hidden sidebar instead?
^ add a listener for the buttons, then use the click() method to select one of the actions (radio inputs) and after that call the click() method on the submit button. That's it :)
^ obviously, you have to hide a sidebar at each load, but you can do it with the MutationObserver just fine, I think
 
@OlegValter I added about 10 lines of code.. :) I think I'll finish the radio-box move, so I have something complete on that. Then I'd like to fix the buttons.
And after that, changing it to redirect seems like a good idea to try out :)
@OlegValter The page doesn't actually reload. Just bits of it.
 
@Scratte I meant the sidebar widget load, not the "load" event :)
 
@OlegValter I just hide it once.. and it stays hidden.
This one: js-actions-sidebar
I have the daunting task of naming stuff now :O
 
10:59 PM
If I add this to moveRadios() is works fine:
The name is moveRadio()..
        if (!isReviewActive())
            return;

        // ------ New code begin                   // "s-sidebarwidget"                 // js-review-actions
        var actionBox = document.querySelector(`.${config.classes.choiceRadios.widget}.${config.classes.actions}`);
        if (!actionBox)
            return;
        console.log("actionBox",actionBox);

        // const actionRadios = config.ids.custom.actionRadios; // "ReviewSuggestedEditsRework-ActionRadios"
        const { ids : { custom : { actionRadios} } } = config;
And change this at the end:
//        moveToFilterLine(fieldset);
        moveToFilterLine(actionBox);
        // This is the BIG radio button box:
//        removeElement(config.selectors.actions.radioActionsBox);
Though I think it broke my audit-detector :)
 
@Scratte ah, you just hide the whole class, sorry nope, read the code, double sorry (I don't really remember if the sidebar stays the same or not)
 
Yup. If I delete it, it doesn't get updated.. and there's no turning on any of the radios that I moved previously. So now I just deleted the "used" one and bring it the new.
If I don't swap it out, the previous choice is kept on the old radio, since that never gets an update.
But I imagine that they add the event-listeners based on the hierarchy of class names.
I also wouldn't be surprised if they're going the same thing that I am.. just swapping in a new box.
 
11:20 PM
@Scratte I can probably tell that from the source, but that will take some time
 
@OlegValter Naah.. don't do that.
 
@Scratte frankly, what I don't get (sorry, I might be too distracted) is why do you remove the actionBox at all?
^ why not keep it and set it to display: none? This removes it from the document flow, so it does not take space
 
I have two different options. Either make buttons instead of radios, or keep the radios. In either of those cases, they should be moved to the same line as the filter-button.
If the choice is to keep the radios, it seems easiest to just move them, instead of creating new ones.
When I move them, they are active.. until a new review is loaded. Then they just die, while a new box is put into the now hidden sidebar.
Perhaps it's only put there because the old is gone :)
I think that when I commented out the removeElement(config.selectors.actions.radioActionsBox); but moving the content of what was inside it, then no new box was inserted.
 
11:43 PM
"I started using Stack Overflow not so long ago and I'm a little lazy to read all the rules." It is little funny.
 

« first day (361 days earlier)      last day (1091 days later) »