« first day (349 days earlier)      last day (1075 days later) » 

10:00 AM
I think the rest (with or without these optimizations) looks nice
 
@OlegValter Oh. That is not jQuery, that is a reference to the variable?
 
^ you could go for an async/await syntax for readability, but I know there are people who prefer chaining then/catch and have no quarrel with them :)
@Scratte yes. Damn! I forgot single backticks mark inline code
3. Bonus: merge thePost and .post-signature.grid--cell selectors :) Just querySelectorAll immediately with `${thePost} .post-signature.grid--cell`
 
But how do I know that the child have the same class as the parent?
Also.. for Answers, thePost not a class, it's an id.
 
@Scratte I am going off of what you provided :) Re: same class - why would you need that? #myId .post-signature.grid--cell means : select an element with an id myId and then any child of it that has the post-signature.grid--cell on it
ouch, wrong colloquial - or not, nevermind
 
Oh. I thought The querySelectors would fetch elements that have all of the terms satisfied :D
Is that what the space means? "And then any children that satisfies the following"? :)
When I get the editor user card, I will try to play with this :) Thanks :)
Funny since I had a lot of doubts about the reponse.text() and the parsing of that :)
 
10:21 AM
@Scratte not necessarily - that depends on the selector - they actually have a horribly complex semantics :)
@Scratte yup, space actually means inheritance :)
hint: if you specify several selectors separated by comma (in one string) in a querySelectorAll, you can get all the elements needed in one go, ordered exactly as specified
 
Ha! I did not know that. But for for own readability, I may split them.
 
This is why space, comma, etc are important in selectors: developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/…
a TL;DR: > -> direct (first-level) children only, ~ -> sibling elements, white space - children anywhere down the tree, + -> immediate siblings
 
@OlegValter Thank you. "Combinators" will be a good read :)
 
@Scratte NP :) CSS selectors is a dark art very close to regular expressions
 
I've seen those used with Stylus too. I thought it was just magic! I couldn't work out how it worked.
I tried every character I could think of.. > and < and ! and / and whatever.. :D
I searched for "Stylus documentation rules selecting".. and nothing came up :D
This is why it takes knowledge to know what to search for.. I feel another rant on closing posts on Stack coming up inside me :)
 
10:30 AM
@Scratte sometimes it can really be an arcane art - the spec by now is 4 levels and is massive. After all, this is basically the backbone of CSS as a language
 
Hello :)
 
@OlegValter But.. that page is so short :O
 
@Scratte well, this is rather basic for a web dev (until you start to apply this to real-world use cases, though) :) But of course not so easy for others
 
Just like regex, only the regex start page is not so short.
 
10:36 AM
@OlegValter Ahh.. the Combinators and Selectors from hell :D ..or heaven, depending on perspective :)
 
@Scratte and that's, thankfully, not the BNF notation :)
 
But seriously.. that is the page for anyone wanting to personalize a page just using CSS styling
 
@Scratte heven/hell - it is a godly bliss when you want to select a couple of elements by their classes and a hellish endeavour if you need a rather complex one (for example, third paragraph element having class X, attribute Y, starting with Z :) But that is a rather simple one)
@KevinM.Mansour hi!
 
11:01 AM
A good day to All :)
 
11:33 AM
This is what I meant. This was a good edit. Yet two users rejected it. One of them have no point in the Java tag. The code removed in that edit is absolutely redundant.
The declaration is an ArrayList<String>..
But I guess one could put it down to personal choice too.
But "The edit does not improve the quality of the post. Changes to the content are unnecessary or make the post more confusing." does not make any sense. I would speculate that the last one just picked what the first one picked :D
 
12:09 PM
@Scratte I saw a lot of cases like that. :(
 
@KevinM.Mansour Yes.. I saw that somewhere else :)
 
12:47 PM
Yay!.. Check this out!.. with user cards :) and without my personal CSS :)
 
@Scratte You done great work today .. It is best a lot than standard.
:)
Good Luck :)
 
1:02 PM
Thank you :)
 
1:22 PM
I installed Spetric user-script but I can not see it on page
 
1:33 PM
Which one?
 
// ==UserScript==
// @name         StackFocus 2.0
// @namespace    github.com/SpectricSO/stack-scripts
// @version      2.0
// @description  Cool stuff
// @author       SpectricSO
// @include      https://*stackoverflow.com/*
// @include      https://*serverfault.com/*
// @include      https://*superuser.com/*
// @include      https://*askubuntu.com/*
// @include      https://*mathoverflow.net/*
// @include      https://*.stackexchange.com/*
// @exclude      data.stackexchange.com*
 
Hmm.. Is this @description Make reviewing nice again! too much? :)
@KevinM.Mansour On mobile or on desktop?
 
2
Q: Stack Focus v2.0

Spectric Screenshot / Code Snippet About Personalize your Stack Exchange experience. Inspired from this question. It provides you to ability to toggle the visibility of certain elements on the page, including: The "Find a Job" category on the left sidebar The Teams advertisement on the left sideb...

Desktop
 
Is it active on the page?
 
I mean How to run it.
yes, maybe
 
1:36 PM
Green means active. It it's not listed in the dropdown it means that it's not considered for the page.
Ahh.. I do not know about ViolentMonkey. What happens when you change the bar?
Oh. Never mind. I see. It's active.
 
@Scratte "Change the bar" What do you mean with change bar;
@Scratte No Problem. I were not Clear.
 
There's a tiny little var there on each of the scripts on the left side. I see two of them are "off" and one is "on" :D
I have installed it now.. and I do not know where to find the settings :D cc @Spectric
Can you add an image to your Stack Apps post that shows or explains how to access the settings?
I expect the default is to include everything.. I'm running it, but I can't see any changes to my UI :)
 
@Scratte Yes they are other scripts;
@Scratte This what I am asking about;
But i do not see any error in Console;
@Scratte The other scripts I disabled as they maybe override this scriptl
If Spetric here maybe he find setting;
 
I do not know :) Maybe Spectric will explain later :)
 
He just write his setting html div into the page but it is not working;
Thanks anyway :)
 
1:46 PM
Ahh.. I found it. I think it needs to get a lot more attention on the Stack Apps post "It can be toggled with the Ctrl + Q shortcut.". I have pressed "Ctrl+Q" and it opened up and.. I think I found a bug
 
@Scratte Yay! worked Thanks for Explaining
 
@KevinM.Mansour I just read the Stack Apps post.. very slowly ;)
"It can be toggled with the Ctrl + Q shortcut." needs an h2 header :)
 
@Scratte I'm on it ;)
 
Add "The default setting is that everything is set to show" too :)
 
I removed the images because they were taking up too much space and caused the reader to lose focus.
Yep.
 
1:53 PM
At least you're getting feedback :)
 
I fixed by changing top to top:15%; and height to height:75%;
Working Great;
 
The problem is that I cannot make my screen higher.. I have a laptop :)
 
Hmmm... the modal should be autofitting
 
Is there a minimum/maximum?
 
Try applying min-height:fit-content
 
2:07 PM
I fixed by changing top to top:15%; and height to height:75%;
 
Yep. I saw. That should work too
 
@Spectric But.. even if that works, it will only work for me. Not for others using it :)
 
Could you send a screenshot of what it looks like for you?
 
Maybe from Windows 10 Microsoft Edge Chromium 90
 
Doesn't look too bad...
Where's the problem?
 
Yep. min-height:fit-content should do it.
 
I fixed that bug by changing top to top:15%; and height to height:75%;
It works for 12.5 Screen Laptop
 
That should only work on specific screen sizes.
 
@Spectric Yes temporary solution for my device.
 
I think I've found the issue. Height is set to 50% which might be too small for devices.
 
2:14 PM
@Spectric But at all; You created great script it saved my time.
 
Thanks
I'll roll out a fix
 
@Spectric I set height to 75% and it works well.
@Spectric Send me before roll out to test on my very small screen :)
 
No problem.
 
@Spectric Good Luck :)
 
Thanks
I should probably either use Javascript positioning or wrap it in a flexbox
 
Those are actually useful...
 
@Spectric Not useful for meand maybe some users :)
No Problem;If you can done that; I will be Thankful;
 
Sure, I'll add support to hide those
 
@Spectric I will try also to add by my self :)
 
2:42 PM
Worked; I can hide now Watched Tags on Public Q&A
and Ignored Tags
Yay! Worked this V3.0
Anyone can test it and give me feedback :)
// ==UserScript==
// @name         StackFocus 2.0
// @namespace    github.com/SpectricSO/stack-scripts
// @version      2.0
// @description  Cool stuff
// @author       SpectricSO
// @include      https://*stackoverflow.com/*
// @include      https://*serverfault.com/*
// @include      https://*superuser.com/*
// @include      https://*askubuntu.com/*
// @include      https://*mathoverflow.net/*
// @include      https://*.stackexchange.com/*
// @exclude      data.stackexchange.com*
 
@Scratte I don't understand why they rejected it as "no improvement" - that's not the case. I am usually much more inclined to reject with an "attempt to reply" reasoning, but I have a specific guideline for that: the post author must not be active for a while. Whic is also not true in this case, they are absent for 5 months, I think it is reasonable enough to consider improving code if one can
 
2:58 PM
@OlegValter Think Different :)
 
@Scratte I am more interested in what the first one was thinking about when choosing "no improvement" [maybe what you mentioned - preference?] (btw, I know this user - crossed paths because they have contributions to the GAS tag)
 
There's a GAS tag? :)
What I mean is that the code works. One would argue that picking one over the other is a matter of preference. Just like (!!myVar) :)
 
@Scratte we absorbed it :) Joking aside, by GAS I meant , not the GNU Assembler. The poor folks on had to endure "how to add rows to the spreadsheet" until we reached an agreement ("slightly" pissing off Cody in the process because for a while, Meta was filled with posts about apps script) that goes away
@KevinM.Mansour ?
 
I thought GAS was a joke. As in a reference to a flammable tag :D
 
@OlegValter Error. But I found Solution :)
 
3:06 PM
I'm having some issues with the $(thePost) :)
I'm trying out this:
console.log("thePost",thePost);
...snip...
.then(data => {
     // developer.mozilla.org/en-US/docs/Web/API/DOMParser
     var userCards = new DOMParser().parseFromString(data, "text/html")
                                    //.querySelector(thePost)
                                    //.querySelectorAll(".post-signature.grid--cell");
                                    .querySelectorAll('$(thePost) .post-signature.grid--cell');
 
@Scratte :) No, sorry, it is a common abbreviation for Apps Script
 
which prints: thePost .question
but it also gives me this error:
 
@KevinM.Mansour ?? "Think Different"
 
DOMException: Failed to execute 'querySelectorAll' on 'Document': '$(thePost) .post-signature.grid--cell' is not a valid selector.
Changing single quotes to double quotes did not make a difference.
 
@Scratte backticks, not single quotes :) Oh, and curly brackets, not curved :)
 
3:08 PM
Did I miss something or.. is my browser broken? :D
 
Thank you!.. I had not quessed that in a million years.
 
@OlegValter I mean mostly reviewers have different point of view for every question :) So everyone Thinks different :)
 
@Scratte I see you still think $ means jQuery [``$(thePost) is valid jQuery, but outside the string, obviously] :)
 
It's the same in PowerShell. The $ inside a quoted string will evaluate and replace in place :)
It just takes a while to get over the "Argh!.. jQuery"-reaction :D
It works! It works! :)
 
3:29 PM
Next question. How do I change this to JavaScript? $(document).ajaxStop(function() {...})?
Some say to override the XMLHttpRequest.prototype.send function
But.. is looks like a send. Not a fetch..
 
@Scratte yes, and shell scripting :)
@Scratte never do that, never override anything on a prototype of a built-in object (unless, of course, you add a polyfill)
@Scratte btw, can you remind me what are you trying to achieve ?
 
@OlegValter Is this overriding? (I do not know what a polyfill is. Or I do, but I forgot :'()
@OlegValter When my page loads, lots of stuff isn't put into the page yet. It's still waiting for a response from Stack. So lots of stuff that I try to find comes back null.
Using the run-at directive doesn't change that.
 
3:46 PM
Uncaught TypeError: Cannot set property 'borderRadius' of undefined
In
$('.s-input').style.borderRadius = "10px";
 
Example: StackExchange.question.getQuestionId(); will return null for me in a user script always. (It doesn't work in review, so don't try it there). But if I run it in the console, it will give me the id. But that's because I'm way slower than my user script manager ;)
But when I put it into a $(document).ajaxStop(function() {...StackExchange.question.getQuestionId();...}) it gives the id.
 
@Scratte basically, yes. Times have changed, you will find a lot of old code just doing whatever to built-ins, but it has been considered a bad practice (because it breaks encapsulation - any other script on the page gets the modified object)
 
@OlegValter I see.. so what options are there? :)
 
@Scratte ah, ok, thanks - then I remember correctly (wasn't sure what's the context)
 
@KevinM.Mansour Sorry. Can't help. I do not know how jQuery works.
But I don't think you should call methods on elements before you have checked if they are null or not.
 
3:54 PM
@KevinM.Mansour obviously there is no .s-input found :) Hence no style, hence undefined, therefore no property borderRadius on undefined
 
I found Solution anyway beacause .style.borderRadius works only with document only like below
document.querySelector('.s-input').style.borderBottomRightRadius = "10px";
Works Fine :)
But I am just surprised :)
 
Yes, or if the method doesn't exists, then obviously also.. it will complain :D
@Scratte Is it possible to create an eventhandler for an ajax response?
 
^ I am tired: disregard the first sentence of the last comment. The wrapper object simply does not have style property, it is not the same as Element. With DOM API you get back an instance of Element
if you want to preserve jQuery, use $(<selector>)[0].style - because this is how you get the wrapped element
 
@OlegValter I happy that I helped Solution anyway
 
@Scratte not many, one is, of course, adding the interceptor as specified - I guess in your case it will work fine
 
4:02 PM
@OlegValter Thanks for Explanation :)
 
@OlegValter Heh.. so it's either jQuery or hacking the prototype :)
 
@Scratte give me a sec :)
 
There's no rush :) Take all the time in the world :)
 
@KevinM.Mansour NP :) Btw, what's the deal with word capitalization?
 
@OlegValter In the word "Explanation" Right?
 
4:06 PM
Hmm.. Kevin lives on "Earth" :)
 
@KevinM.Mansour yes, and now with the "Right" :)
 
Else it's common in German to use capitalization of nouns :)
 
@OlegValter Just for styling purpose Also I started to learn Germany like @Scratte said :)
 
@Scratte I thought it is not that common nowadays?
 
@OlegValter Just create style for the word :)
 
4:08 PM
@OlegValter I think it is for proper German. I'm not sure. It's been a while since I tried it :)
 
Also I end sentences with ";" instead of dot ".".
 
@KevinM.Mansour why? :)
 
@Scratte For Javascript. Because I am more familiar with it with ending vars and functions and also it is near my right hand than ".". I see it more comfortable for my hand.
 
@KevinM.Mansour ???
 
@Scratte But I am started to write slow to learn use "." instead of ";".
@OlegValter Just test it on your keyboard ";" will be near third finger in your right hand but if you want to use "." you must make your hand bottom a bit to click on "dot"
anyway , Thanks for help.
 
4:14 PM
@KevinM.Mansour OK. For me the ; is harder then the . The ; needs a shift too, while the . doesn't :)
 
@Scratte For me it does not need shift ... Interesting :)
 
I'm using a local keyboard. It also has an "æ" on the right little finger, next to the l :)
 
@Scratte What is "local keyboard" do you mean keyboard on windows or Desktop PC keyboard for I am using Windows 10 Laptop HP
 
@Scratte can you remind me what is the real use case for waiting until script load (I am getting really tired, my brain barely functions)?
 
@KevinM.Mansour A keyboard that is only produced for one nation or a few nations because they have different letters :) Usually the layout changes. It doesn't just add keys.
 
4:21 PM
@KevinM.Mansour It should be $('.s-input').css('border-radius', 10px');
jQuery should not be mixed with vanilla JS
 
@OlegValter Have you considered sleeping? :)
Use case:
function highlightSummary() {
    $(document).ajaxStop(function() {
        var summary = document.querySelector(".fc-red-800.mt8");
        if (summary) {
            summary.textContent = summary.textContent.trim().replace(/^Comment/, "Summary");
            summary.style.fontSize = "200%";
            summary.classList.remove("fc-red-800");
            // summary.style.color = "var(--red-500)";
            summary.style.color = "var(--orange)";
        }
    })
}
It I remove the $(document).ajaxStop(function() { and matching line, summary will be false/null. Always. For me :)
 
@Spectric Uncaught SyntaxError: Invalid or unexpected token
@Spectric Fixed
      $('.s-input').css('border-radius', "10px");
 
@Scratte can you link me to the full context (code)?
 
4:38 PM
Sure :) pastebin
 
@Scratte so, again, why not wrap the whole thing in a load event listener? :) Currently, you run all of the functions immediately - as soon as the userscript loads
 
^ it runs, but it's not finished yet. I still need to put in more stuff of yours :)
 
@Scratte I asked for the full code because I grew suspicious as soon as I saw the ajaxStop part :)
if you call the functions inside the handler, everything should be just fine
 
If you mean a a window.addEventListener("load", () => {...}) it doesn't work.
 
@Scratte where do you put it? In the context of the full code
 
4:43 PM
The full code :)
 
@Scratte can you show me the exact version?
 
It's gone..
But I can make a new one :)
 
$('.s-input').css('border-top-left-radius', "10px !important");
 
because I really can't wrap my mind around SO making a separate request to get the user card
 
Not working when I input it on Console. it gives :
n.fn.init(3) [input.s-input.s-input__search.js-search-field.blr0.h100.js-search-autocomplete, input#js-site-search-txt.s-input.s-input__sm.w100.h100.site-filter-input, input#feed-url.s-input, prevObject: n.fn.init(1), context: document, selector: ".s-input"]
 
4:46 PM
@OlegValter It's not even the user card. The example I gave was the "Inline | Side-by-side | Side-by-side markdown" that it cannot find :)
 
@Scratte well, I saw the getUserCards first, so I referred to its ajaxStop :)
 
@OlegValter Fair enough :)
Oh no. The example was actually the Summary div, that it cannot find.
Of course I can put the entire script into a $(document).ajaxStop(function() {..script here..}), but it still doesn't get me out of jQuery
 
@KevinM.Mansour:
> Note: .css() ignores !important declarations. So, the statement $( "p" ).css( "color", "red !important" ) does not turn the color of all paragraphs in the page to red. It's strongly advised to use classes instead; otherwise use a jQuery plugin.
 
@OlegValter huh .. So How can I use classes to set border radius or any CSS?
 
@KevinM.Mansour why did you want to use !important rule in the first place, btw?
 
4:55 PM
But I really tired from user-script of two or three lines. I do not know How to work with one hundred line of user-script.
@OlegValter I want to set border radius to Stack Overflow bar of searching But It did not work ; So I tried adding !important
 
@KevinM.Mansour why don't you want to remove the blr0 class from the input first? The one that has the following ruleset:
 
@OlegValter Is that overide my CSS? maybe. But what is that?
 
.blr0 {
    border-top-left-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
}
@KevinM.Mansour it is your CSS that tries to override the rules declared by the stylesheet of the page :)
 
@OlegValter Yes, I wanted to Override that? But I am surprised with blr0 I saw it but never thought it will override my CSS.
 
Here's a smaller script that uses what you have previously given me:
// ==UserScript==
// @name         Testing.. ready :)
// @version      0.1
// @description  I have no words.
// @author       The Cookie Monster
// @include      /^https:\/\/stackoverflow.com\/review\/suggested-edits.*/
// @exclude      /^stackoverflow.com/review/suggested-edits/(stats|history)
// @grant        none
// ==/UserScript==

((w, d) => {

  'use strict';
  w.addEventListener("DOMContentLoaded", () => {
    console.log("DOM parsed and loaded");
  });
  w.addEventListener("load", () => {
This is what my console gives me
Note that it's set to only fire in a suggested edits review.
Note that I do not expect the console output nor the functions to be executed in the order that I present them.
I'm simply demonstrating that window.addEventListener("load", () => {...}) doesn't fix it for me :)
 
5:12 PM
    $('.s-input').removeClass("blr0");
Works only with Console but does not work in Code :)
Maybe timeout issue.
 
@Scratte HA! The datetime that the console puts in by default is just priceless here. There's 500 milliseconds from the "Fully loaded" until the ajaxStop fires :) That should be enough for light to go from Europe to a server in the US and back again with a request/response :)
 
5:27 PM
ok, I think I know the drill
 
Solved and Finished :)
 
there is a request to the /review/next-task/<id here> endpoint
 
@KevinM.Mansour Very nice!
 
@Spectric Thanks I wouldn't do that until I found your great Script But I edited to clean something.
 
5:33 PM
No problem :)
 
// ==UserScript==
// @name         StackFocus 2.0
// @namespace    github.com/SpectricSO/stack-scripts
// @version      2.0
// @description  Cool stuff
// @author       SpectricSO
// @include      https://*stackoverflow.com/*
// @include      https://*serverfault.com/*
// @include      https://*superuser.com/*
// @include      https://*askubuntu.com/*
// @include      https://*mathoverflow.net/*
// @include      https://*.stackexchange.com/*
// @exclude      data.stackexchange.com*
Source Code; But I recommend to release what I have done but you edit it to make it looks more better :)
 
5:47 PM
@OlegValter So that's what's messing up my script? :)
So far I added a function wrapper:
function axajStopWrapper(foonction) {
    $(document).ajaxStop(function() {
        foonction.apply(this, arguments);
    })
}
And then at the end I call the methods with:
axajStopWrapper(highlightSummary);
I can optimize it, by putting all the functions into just one, and then just putting the wrapper inside of that. But I kind of like that some of them are fired before the request/response comes back.
But my initial quest was to do the same thing with vanilla JavaScript :)
 
6:50 PM
so, finally, I think this is much easier:
    function highlightSummary(summary) {
        console.log("highlightSummary: ", summary);
    }

    function highlightSummaryWithAxajStop(summary) {
        console.log("highlightSummaryWithAxajStop: ", summary);
    }

    const mo = new MutationObserver((list) => {
       const nodes = list.flatMap(({ addedNodes }) => [...addedNodes].map((node) => node.nodeType === Node.ELEMENT_NODE && node.querySelector(".fc-red-800.mt8")));

       const summary = nodes.find(Boolean);

        if(summary) {
^ easily abstracted to an analog of Puppeteer's waitFor :)
 
Heh.. isn't that a hack? :)
Not sure I completely understand it.
 
Is there user-script to customize Chat Page better than that Ancient Way :)
 
What is the different between your highlightSummary and highlightSummaryWithAxajStop?
@KevinM.Mansour How do you want to customize it?
 
7:07 PM
@Scratte A bit of customization. Make things bigger (Somethings)(Remove unnecessary things) and make things more modern.
 
@KevinM.Mansour Modern is a.. dangerous term, no? I mean does it mean better or worse? And which is which for whom?
What is unnecessary? For you it's probably not the same as for me.
If you just want to make things bigger, there's a zoom option in your browser :)
You can use crtl and the mouse scroller to zoom in and out.
The thing about bigger is that is also.. takes away thing that there is no longer room for.
But I do not know of a chat user script that does those things.
 
I think that things is unnecessary.
 
Try typing in one line. Then hold down shift and press enter. Then type in a next line. Then press "fixed font" and send your message without pressing "send" :)
As for the other things, the first box you highlighted is very useful if you are in many rooms but do not want to have a tab open for each of them. But you still want to know if messages come into one of the rooms.
 
At All I will search if I found useful one I will tell you :)
 
I think you will find that last one very useful. Both the help and the faq are useful.. to anyone that is not 100% comfortable with how Stack chat works :)
But. Don't use a userscript for stuff like that. Just use an extension and block the elements.
@OlegValter Thank you for looking into this. When you have time and have slept. I think I need a little help understanding how it works.
 
7:22 PM
what is this script supposed to do?
 
@double-beep to do of what?
 
@Scratte nope, none of the sorts :) We are just waiting for the selector to appear in the DOM. This is a crude implementation, though - I will refine it when I get up
 
@double-beep Ahh.. it's suppose to fix this
 
how are you highlighting it?
 
@Scratte I assume you ask me? No difference, I just copy-pasted yours - I think the second one is not needed anymore
 
7:24 PM
@double-beep Huh? Who are you addressing?
 
@double-beep Add message id in the url like #52144484
 
@OlegValter OK. Get some sleep. I will ask you about it when you wake up :)
 
@Scratte sorry :) I'm not sure what summary is highlighted and how
 
2 hours ago, by Scratte
This is what my console gives me
 
@Scratte sure
 
7:27 PM
@double-beep Click on arrow then click on permalink
then paste URL in Chat :)
 
@double-beep If you are referring to console log printout, then it's about me having to wrap things in an ajexStop() call when I make a user script. If I don't, the elements are null. I just have two methods and one of them is wrapped and the other is not.
Are you on mobile or something like that? :)
So I asked how to do it differently using vanilla Java and not overriding prototypes :)
 
@Scratte - re: request - I opted to go check if I come up with a MutationObserver is that I want to avoid overwriting methods on built-in objects as much as possible (IMO, if you find yourself in need of intercepting network requests, the is a big issue with the chosen approach). I do not think there is a better way for listening to XHR requests, though
 
@OlegValter I have tried to find out if I can create an eventhandler for them. But I keep running into the issue that I need the object for which I want to create an eventhandler for :)
I'd be fine with having an eventhandler for the prototype though.
Somehow it also makes it more clear what is going on in the code.. I think.
I am waiting for the event.. that a response comes in. So why not just have that clear in code? :)
 
Sorry. It might not be Right Place; I have Answer to this question; But I think it is very low quality; So I answer it or not?
 
It's going to be closed in 3..2..1.. almost there..
 
7:36 PM
@Scratte You are so funny; Thanks :)
almost there :)
 
And just for the record. I do not think that is a bad Question. I think it's phrased badly. It's just a how-to Question. But the people of Stack Overflow don't like how-to Questions, which is a shame. If they had posted "Please help debug my tictactoe game. Here's my very specific code. I expected this and got this" is would have made it. Despite that no one ever would find it useful.
 
@Scratte Fo that I asked I do not waste my time toanswer fater that it is getting closed;
Also some of my answer got deleted because question also deleted.
 
@KevinM.Mansour Yes. That happens to me too :)
 
Yay! Question has been closed :)
 
@Scratte no, sorry, this is an awful question. There is a difference between "how to create a recursive generic type filtering out keys by the type of value" and "I want to create a language switcher (dropdown button) with country flag using html css, vanilla javascript & googletranslator". That's just a requirement dump
 
7:39 PM
@KevinM.Mansour I do not like that it was closed. It's not a bad Question. They are certainly not the only ones that want to do this.
 
Like what you expected
 
@OlegValter Pfff.. that can be rephrased :) By any expert :)
 
@Scratte I am sad; I have the answer for it; I will add as simple comment it might help him :)
@OlegValter hehe
 
@Scratte really, sorry, folks, that's just a code request. This is not a "how to" question
 
@OlegValter Code request are not off-topic.
 
7:41 PM
@Scratte But no one will edited
 
Only if they are too broad or not detailed enough.
 
@Scratte No I think they aree off-topic
 
@KevinM.Mansour Every post is a code request.
 
@Scratte But there is different between one single line and 10 or more line.
 
@KevinM.Mansour Not really. There's a difference between 25 lines and 2500 lines.
I still need to make some changes to our script. I need the stats of the editor. But I'm having trouble with the response.json :)
 
7:44 PM
@Scratte anyway , Good Luck with user-script.
 
@Scratte trouble?
 
I do not understand this construct const { items, } = await res.json();
I'm trying to get the "quota_remaining" from the result :)
If I do it like so:
    const result = await res.json();
    const items = result.items;
I can get it with result.quota_remaining
But I am curious about this const { items, } that seems to only get the items into a variable also called items..
 
const { items, quota_remaining } = await res.json(); should work as well
 
But.. how does that work? :) what if I want the quota is be in a variable called myVeryLowQuotaOfToday ?
 
const result = some_json, someVariable = result.quota_remaining;
like you mentioned
 
7:54 PM
@Scratte that's called object destructuring :) Everything between curly brackets is a property of the object obtained from await res.json(). From these names, variables are created with declaration (let,const, or var) specified before the opening bracket
 
Heh.. OK. So the construct only works if the name is identical?
@OlegValter Is that special for the await? Or will that always work for any json?
 
@Scratte by default, but not necessarily. There is a special syntax for renaming (in the example, the variable created is propA): const { propertyA: propA } = { propertyA: 42 }
 
I see. It still looks very strange to me. Kind of mind blowing.. I burned down the quota trying to work it out :)
 
@Scratte that's a relatively new, but an extremely cool feature :) much cleaner than const a = obj.a, b = obj.b, c = obj.c; and such
 
@Scratte you don't use a key?
 
7:59 PM
@double-beep No :) 300 for today..
 
@Scratte for any object. JSON in JS is just an object - once you parse the JSON string, it is always an object [apart from primitives that is] :)
 
you can use U4DMV*8nvpm3EOpvf69Rxw(( from api.stackexchange.com/docs/js-lib
 

« first day (349 days earlier)      last day (1075 days later) »