« first day    last day (1424 days later) » 
03:00 - 18:0018:00 - 20:00

3:56 AM
@ArtOfCode API, y u no jQuery!?
there's on /docs/ however
 
 
2 hours later…
6:19 AM
@double-beep How do you know which ones does or doesn't have jQuery?
 
 
3 hours later…
8:49 AM
I don't think the quota is reset. I just got this reply: {"items":[{"close_vote_count":2,"last_activity_date":1590133829,"question_id":61949925}],"has_more":false,"quota_max":300,"quota_remaining":163}
.. I did not do 137 requests today
This was my request: https://api.stackexchange.com/2.2/questions/61949925?order=desc&sort=activity&site=stackoverflow&filter=!)5IW-1CBJh-k0T7yaaeIcKxo)Nsr
 
@Scratte resets 24 hours after you start making requests, not at 00:00
 
@ArtOfCode Ahh.. thank you. That's a relief :)
but I still don't recall making that many requests. I thought it would have been less than 30
Perhaps it's counting things that I'm not aware of doing.
 
user12867493
9:12 AM
I'll start working on my script in a few hours
 
user12867493
Got to do some work first
 
user12867493
Hopefully, I can get a beta version today
 
@Daniil There's no rush.. it's just nice to have :)
 
9:50 AM
@Scratte run !!window.jQuery at the console.
 
!! <-- is that a double negative? :)
 
true, if that's defined, it will return true, if not false
 
as a normal human the above could be read as Run away.. there's window.jQuery at the console :)
 
10:19 AM
@Daniil will you post that in a GH gist or something?
 
user12867493
Yeah, I'll put it in a gist for you to try out, if there are no major issues I'll then make a repo
 
user12867493
I'll make a secret gist
 
user12867493
I should continue on it within a couple of hours
 
@Daniil pretty sure there's a SO post about the => operator somewhere.
 
user12867493
10:42 AM
My key:
 
user12867493
5uXDnm8574pzkaCadaFv)A((
 
oh, you registered for an API key?
 
user12867493
Yeah
 
do you use jQuery by any chance?
 
user12867493
@ArtOfCode why doesn't this work?
 
user12867493
10:49 AM
I just realised my error nvm
 
user12867493
Actually, it still doesn't work:
 
user12867493
var count=makeAPIRequest(urlneeded, results=>{results.items[0].close_vote_count});
 
the second argument is incorrect
 
user12867493
What is the second arguement supposed to be?
 
Oops..
 
10:53 AM
@Daniil parameters
var parameters = {filter: 'filter', anotherOption: 'value'};
also, the function doesn't return the count, but the data from the API (e.g. if you store that to a variable you need count.items[0].close_vote_count)
 
user12867493
I don't get it
 
user12867493
What is filter and value?
 
user12867493
I already have that URL in urlneeded
 
that is {order: 'desc', sort: 'activity', site: 'stackoverflow', filter: '!)5IW-1CBJh-k0T7yaaeIcKxo)Nsr'}
and the first argument should be https://api.stackexchange.com/2.2/questions/61930678
 
user12867493
10:59 AM
What is 'anotheroption'?
 
@Daniil just an example.
 
user12867493
Also for the site parameter, do I just replace that with the name of the site?
 
user12867493
Actually I'll make it SO only for now
 
user12867493
Too complicated
 
so, use site: 'stackoverflow'
 
user12867493
11:04 AM
var count.items[0].close_vote_count=makeAPIRequest(urlneeded, parameters);
 
@Daniil The makeAPIRequest returns the entire json if I understand it correctly.
 
var count=makeAPIRequest(urlneeded, parameters);
console.log(count.items[0].close_vote_count);
@Scratte yes
 
user12867493
Do you know of a userscript that uses the api on a per-site basis?
 
user12867493
Maybe I can get the code from there
 
so you should maybe make it var data = makeAPI.. and then count=data.items[...
 
user12867493
11:07 AM
@double-beep doesn't work
 
user12867493
count.items is undefined
 
in makeAPIRequest function, add console.log(url) before const resp = await fetch(url);.
what's the output?
 
user12867493
Which doesn't work by itself
 
the mistake is in the function
gimme a sec
 
11:11 AM
There's a ? missing, that's all
 
user12867493
:)
 
then pass https://api.stackexchange.com/2.2/questions/<id>? as the first parameter
 
url = url + '?' + Object.keys(parameters).map(k => ${k}=${parameters[k]}).join('&');
disclaimer: I have no idea what character is used for strings.
 
user12867493
Still an error
 
user12867493
count.items is undefined
 
11:14 AM
But.. what is url when you do that?
 
user12867493
Outputting count just says pending
 
OK. But you added the "console.log(url) before const resp = await fetch(url);" to your code now?
 
user12867493
yes
 
but it didn't log it?
 
user12867493
It did
 
11:18 AM
@Daniil that's from await (promises)
 
@Daniil what was the result? :)
 
user12867493
How have I used up 300 quota already?
 
user12867493
@Scratte The correct url
 
user12867493
@double-beep ?
 
11:19 AM
@Daniil I'm very puzzled by that.. I have used it twice to see if my correction with ? was good. I am thinking that perhaps browsers go fetch stuff on their own with reloading
 
user12867493
So how do I fix it?
 
user12867493
    count.items is undefined
 
I have to go, will be back shortly.
 
user12867493
@Scratte Your quota does not affect mine
 
user12867493
@double-beep :(
 
11:21 AM
@Daniil No, when I tested the url, I got this reply: {"items":[{"close_vote_count":1,"last_activity_date":1590144449,"question_id":61952894}],"has_more":false,"quota_max":10000,"quota_remaining":9818}
and I only fired it twice
 
user12867493
Looks like it won't be ready today
 
user12867493
No idea how to display the count as well
 
It doesn't need to be ready today.
 
user12867493
How can I query the API for the specific site the user is on?
 
It looks like perhaps you need to not call it with var data = makeAPI.. but perhaps makeAPI....then(data => {console.log(data)});
 
user12867493
11:31 AM
Data is not defined
 
user12867493
Can you put complete code please?
 
Are you using:
var count=makeAPIRequest(urlneeded, parameters);
console.log(count.items[0].close_vote_count);
?
 
user12867493
yes
 
I'm guessing here but try makeAPIRequest(urlneeded, parameters).then(data => {console.log(data)});
without the var count=
 
user12867493
 
user12867493
11:35 AM
Output^
 
user12867493
I got it to work!
 
user12867493
makeAPIRequest(urlneeded, parameters).then(data => {console.log(data.items[0].close_vote_count)});
 
user12867493
Outputs 1
 
Right :) So it's not like a method call :)
 
user12867493
How do I save that 1?
 
11:36 AM
it's keeps the data inside until it's ready.. and when() is like a callback
 
ok, so why do you need a function for that? You are going to call API once, right?
 
user12867493
I dunno, scratte told me to do that :)
 
user12867493
At least it works
 
I was guessing :)
 
user12867493
How do I save:
 
user12867493
11:38 AM
console.log(data.items[0].close_vote_count)
 
var variable = data.items[0].close_vote_count
 
user12867493
data is not defined
 
user12867493
    makeAPIRequest(urlneeded, parameters)
    var count = data.items[0].close_vote_count
    console.log(count);
 
where do you define data?
 
user12867493
    var data = makeAPIRequest(urlneeded, parameters);
    var count = data.items[0].close_vote_count;
    console.log(count);
 
11:41 AM
@double-beep You're saying that the .when() is not needed, right?
 
user12867493
data.items is undefined
 
@Scratte what is when()?
 
sorry.. I meant then()
 
makeAPIRequest(urlneeded, parameters).then(function(data) {
    const cv_count = data.items[0].close_vote_count;
    console.log(cv_count)
});
 
user12867493
Yay
 
user12867493
11:45 AM
It works
 
ohh.. it was the "=>" that was unneeded :) Sorry for using syntax I know nothing about :)
 
that's my fault actually. Writing data => {stuff with data} and function(data) {stuff with data} is exactly the same thing
 
user12867493
How do I display it here:
 
user12867493
 
user12867493
CV's 1
 
11:47 AM
do you use jQuery?
 
@double-beep Ok. Thanks :) But what did you meant by this?
 
user12867493
Um... not sure
 
does your code contain $ anywhere?
 
user12867493
Only here:
 
user12867493
url = url + '?' + Object.keys(parameters).map(k => `${k}=${parameters[k]}`).join('&');
 
11:49 AM
that's not jQuery
 
user12867493
Ok then, no
 
user12867493
Do I have to do some CSS?
 
I don't know about scope and javascript, but I would assume that the variable or constant needs to be defined outside the then() for it to be reachable.
 
@Scratte no.
 
super.. that makes it so much easier :)
 
11:56 AM
except if you mean to access it outside the function in then
 
@double-beep That's what I meant, yes :)
 
then it's private
 
I don't know how Daniil is using it, so I can't tell if it's necessary to access it outside
 
function a() {var b = "I'm private!";}
a();
console.log(b);
compare that to:
var b;
function a() { b = "I'm not private!"; }
a();
console.log(b);
@Daniil it's easier to do it with the help of jQuery than with pure JS
 
user12867493
@double-beep So where do I start? :)
 
user12867493
12:00 PM
I want the same style as the viewed*/*asked*/*active count
 
I expect your first example will not see b.
@Daniil where you do want the information to go on the page?
 
@Scratte yes
add that to userscript's metadata
now you can use jQuery
 
user12867493
Done
 
user12867493
Next to the viewed display
 
user12867493
@double-beep now what?
 
12:06 PM
$('#question-header').next().children().last().addClass('mr16');
$('#question-header').next().append(`
    <div class="grid--cell ws-nowrap mb8" title="Viewed 35 times">
      <span class="fc-light mr2">Close votes</span>
      >here insert the count<
    </div>
`);
start with that ^
 
user12867493
At the top of my code?
 
user12867493
Ok
 
user12867493
What is <div class="grid--cell ws-nowrap mb8" title="Viewed 35 times">
 
user12867493
for?
 
user12867493
especially the 35 times?
 
user12867493
12:12 PM
How do I insert the count
 
user12867493
If I replace it with cv_count it just shows cv_count
 
use ${cv_count}
 
user12867493
Yay it works
 
user12867493
@double-beep can you grab me a question with some cv's for a test please?
 
you should probable change or remove title="Viewed 35 times"
 
user12867493
12:14 PM
 
user12867493
:D
 
correct
@Daniil that's HTML
 
user12867493
How can I implement it across all SE sites?
 
user12867493
Like StackExchange.get.site();
 
FWIW, I published my version.
 
user12867493
12:16 PM
Where?
 
@Daniil you probable need to set sitename to window.location.hostname
 
user12867493
Where does yours show CV's?
 
user12867493
Can't find it on the page
 
under the vote buttons
 
user12867493
Doesn't work
 
12:20 PM
what does the console say about that?
 
user12867493
Your's doesn't run on Travel.SE
 
because you can see delete votes and close votes
 
user12867493
Oh
 
if (canSeeDVs && canSeeCVs) return;
 
user12867493
@double-beep nothing
 
12:26 PM
will you post yours somewhere?
 
user12867493
Mine doesn't work yet
 
user12867493
Won't run on other sites
 
user12867493
Even though I have:
 
user12867493
// @include      /^https://*.stackexchange.com/questions/\d+/*
 
use /^https://(?:[^/]+\.)?(?:(?:stackoverflow|serverfault|superuser|stackexchange|askubuntu|stackapps)\.com|mathoverflow\.net)/questions/\d+/
 
user12867493
12:29 PM
It works now
 
does it show the real CV count?
 
Strange. I've removed all your canSeeDVs and canSeeCVs, but it's still not showing anything, despite that I can see it runs your script :)
 
does the question actually have any CVs/DVs?
 
user12867493
12:44 PM
Oh yes, it does
 
user12867493
It works
 
user12867493
But I like my version more :)
 
yeah, I'll change the location
 
wait?.. you made both yours and double-beep's work?
 
user12867493
Yep
 
user12867493
12:46 PM
Mine is finished
 
@Scratte console?
 
user12867493
Now I'll try to implement it in review
 
Someone closed it.. :( I'll have to find a new Question :)
 
user12867493
Should have 2
 
12:50 PM
CLOSE ALL TEH THINKZ
 
@Daniil Thanks.. maybe not for long, if there are lurkers :)
 
@Daniil that's not easy.
 
user12867493
@double-beep I know
 
user12867493
@double-beep I probably won't
 
Ohh.. the console is not happy: Uncaught (in promise) TypeError: Cannot read property 'getQuestionId' of undefined
I think it's complaining about this: StackExchange.question.getQuestionId();
 
12:58 PM
In L11 and L17 add window. before StackExchange
 
I commented out L11 :)
But it doesn't make a difference. Even the stacktrace is the same. Perhaps it's my stange browser
 
@Scratte set questionId to be equal with window.location.pathname.split('/')[2].
 
Thanks.. I'll need to find a new Question again though. Not sharing it here :D
 
It works :)
I also tried with document.getElementById('question'); but that gave an error too
 
1:12 PM
that doesn't get the question's id, but instead it gets the HTML element that has id attribute "question"
 
Oh.. the learning curve is steep
This is really neat :)
I'll need to make a small change though. If there are none, I still want to see it :)
 
remove && items.close_vote_count and && items.delete_vote_count from L30 and L31 respectively
 
Thanks :)
 
1:39 PM
@Scratte now the location has changed.
I updated the gist.
 
Ohh :)
I made some other changes.. I added a reopen vote count using this filter: '!)rbHxFp0gYkdLgKAljfv'
and I changed the span to a div, so they're on top of each other :)
..but I see your changes are better :)
 
@Scratte so you'd like to show the reopen vote count, too?
updated the script
 
1:56 PM
And the undelete.. but alas, I cannot find those in the filter generator
but for me, they don't make sense since I can't see posts that are deleted :)
 
people who can see deleted posts, can see both DV and undelete vote count
 
It looks nice, but I liked them sitting under the timeline :)
 
>.>
 
Think of all that wasted space there :)
 
function generateAppendElement(innerHTML) {
  const el = document.createElement('span');
  el.innerHTML = innerHTML;
  document.getElementsByClassName('post-layout--left')[0].appendChild(el);
}
Replace generateAppendElement function with that ^
if (!canSeeCVs && items.close_vote_count) generateAppendElement(`${items.close_vote_count} ${items.close_vote_count == 1 ? 'CV' : 'CVs'}`);
if (!canSeeCVs && items.reopen_vote_count) generateAppendElement(`${items.reopen_vote_count} ${items.reopen_vote_count == 1 ? 'RV' : 'RVs'}`);
if (!canSeeDVs && items.delete_vote_count) generateAppendElement(`${items.delete_vote_count} ${items.delete_vote_count == 1 ? 'DV' : 'DVs'}`);
 
2:05 PM
Yes.. I wonder if I should update my local version to 0.3 :)
@Daniil Sorry.. we've been cheating. Playing with double-beep's script
 
2:38 PM
I added this too
generateAppendElement(`${'Quota'}`);
generateAppendElement(`${results.quota_remaining}`);
 
3:08 PM
@Daniil got the issue fixed now?
 
3:30 PM
I'd like to see the script @Daniil made too.. especially because But I like my version more :)
 
4:08 PM
@Scratte use generateAppendElement('Quota', results.quota_remaining);
 
@double-beep won't work, it's a single-arg function ^^^
but you could use generateAppendElement(`Quota: ${results.quota_remaining}`), which I suspect is what you meant :)
 
function generateAppendElement(desc, count)
 
2 hours ago, by double-beep
function generateAppendElement(innerHTML) {
  const el = document.createElement('span');
  el.innerHTML = innerHTML;
  document.getElementsByClassName('post-layout--left')[0].appendChild(el);
}
 
gah, K&R
but nice :)
 
4:22 PM
@double-beep I'm using the one ArtOfCode pasted because I like them below the timeline :)
 
that should be generateAppendElement(`Quota: ${results.quota_remaining}`) as mentioned
 
@double-beep One call looks like this, but two calls look lke this :)
 
user12867493
@ArtOfCode yes I did
 
user12867493
I still have some edits to do
 
user12867493
If there are re-open votes I’m showing them instead of the close votes
 
4:36 PM
@Daniil Awesome. We didn't think of that :)
 
user12867493
So if the number of re-open votes >=1 show them, if not show close votes
 
user12867493
Obviously there can’t be close and re-open votes at the same time :)
 
user12867493
@double-beep Will you be able to help me with some testing (not right now)?
 
user12867493
Just send me a link to a question with re-open votes please
 
user12867493
When I finish
 
4:41 PM
stackoverflow.com/q/61944984 has one reopen vote
 
user12867493
4:55 PM
Thanks
 
user12867493
What is the filter for re-open votes?
 
I'd suggest !YOLQXf.68O4I3*ost.Je3i7xLj
 
user12867493
Ok
 
user12867493
Yep, the reopen votes work
 
user12867493
I'll log delete as well
 
user12867493
5:25 PM
@double-beep I'm making a post on stack apps advertising the script?
 
user12867493
Want credit? (last chance)
 
nope
have you posted it in a gist?
 
user12867493
Ok, thanks :)
 
user12867493
Will do
 
user12867493
Just let me know if you see any issues before I post
 
user12867493
5:26 PM
Give me a sec
 
remove if (url.includes("/questions/") == true)
also the console.log(site) (debugging) and url definition
 
user12867493
So much unindentation :/
 
are you using tampermonkey?
 
user12867493
What debugging?
 
5:31 PM
select all the text and press tab
@Daniil generally, debug messages should be used for testing and that's production
 
user12867493
Ok
 
the filename should end with .user.js
 
user12867493
Now I broke my script
 
user12867493
I unindented and it doesn't work
 
user12867493
I deleted a ) but can't view what line
 
user12867493
5:40 PM
Done
 
user12867493
See new gist
 
don't show CVs if a question is closed
don't show DVs if a question is open
 
user12867493
Yeah I just figured
 
OR don't show any of these if they are 0.
 
user12867493
What's the way to check is closed/open?
 
user12867493
5:44 PM
I want to show if it's 0, the script may not be working
 
then don't show CVs/RVs to 3k-s and DVs to 10k-s
code on L43-L49 is similar to code in L51-L57, similar to L59-65
create a function, then call it with two arguments, the description and the count
also: don't use useless params. Since you're fetching only one question, you need neither sort nor activity parameters
 
user12867493
@double-beep done
 
user12867493
@double-beep done
 
user12867493
@double-beep How?
 
user12867493
@double-beep How?
 
user12867493
5:54 PM
@double-beep How?
 
user12867493
How can I see if a question is open?
 
03:00 - 18:0018:00 - 20:00

« first day    last day (1424 days later) »