13

Is there a way to filter the profile votes list to determine when I voted for a specific question and answer?

The reason I'm asking is I just ran across an eight-year old question showing that I upvoted it and also upvoted an answer. The problem is that the question is clearly off-topic, and I'm relatively sure I wouldn't have upvoted it or another answer on the question.

I already tried "searching" manually through the pages of my profile "votes" history list page by page, but was unable to locate the post/vote. Knowing when my vote happened would let me see what other votes I cast around the same time to see if something fishy is going on.

3
  • 2
    If one of the posts has a low score you could check the vote summary there, which would tell you the dates of the votes; that would help you narrow down when you cast it. Commented May 13, 2023 at 1:17
  • 10
    Alternatively, if it hasn't been edited you could remove your vote, you'd then get a message a long the lines of "You last voted on this question Dec 13, 2017 at 16:55. Your vote is now locked in unless this question is edited." Commented May 13, 2023 at 1:20
  • wow the related links section suggested How to find how many votes I have cast on one user's posts?, which just blows me away (that it did a good job) Commented May 13, 2023 at 9:33

2 Answers 2

15

I made this into a userscript so you can click on the post menu link to begin the search:

enter image description here

Progress toast:

enter image description here

Result toast:

enter image description here

View/install userscript: ( When Did I Vote? | Install )

Works for SOTeams too.

2
7

Try running this in the browser console in any page under stackoverflow.com.

<obligatory "don't run code you don't trust or don't understand in your browser console" here>

It fetches each page (with some delay in between to avoid getting hit with rate-limit) and parses out voting events from your https://stackoverflow.com/users/<user-ID>/<username>?tab=votes page (short-circuits once something is found). It'll print the post ID, vote-timestamp, and page number (of the page in your votes section of your profile page).

let postIdToFind = ; // TODO (number)
let postTypeToFind = ; // TODO "questions" or "answers"
let siteRoot = "https://stackoverflow.com";
let userId = parseInt(document.querySelector(".s-topbar--container .s-user-card__small").href.split("/")[4]);
let millisBetweenRequests = 2000; // avoid getting blocked by rate-limit

async function getHtmlDoc(url) {
  const html = await (await fetch(url)).text();
  const parser = new DOMParser();
  return parser.parseFromString(html, "text/html");
}

let data = (await (async function() {
  let postToFindCreationDate = new Date((await getHtmlDoc(`${siteRoot}/${postTypeToFind}/${postIdToFind}`))
    .querySelector(".question .post-signature.owner .user-action-time > *").getAttribute("title")
  );

  const numPages = parseInt([...(
    await getHtmlDoc(`${siteRoot}/users/${userId}/user?tab=votes&sort=upvote`)
  ).querySelectorAll(".js-pagination-item")].reverse()[1].textContent);

  for (let pageNum = 0; pageNum < numPages; pageNum++) {
    const doc = await getHtmlDoc(`${siteRoot}/users/${userId}/user?tab=votes&sort=upvote&page=${pageNum+1}`);
    const els = [...doc.querySelectorAll(".js-expandable-posts .js-post-expandable")];
    let data = els.map((el) => ({
      postId: parseInt(el.querySelector(".answer-hyperlink,.question-hyperlink").href.split("/")[4]),
      time: new Date(el.querySelector(".relativetime").getAttribute("title")),
      pageNum,
    }));
    if (data.some(d => d.time < postToFindCreationDate)) { return null; }
    // ^optimization relies on traversal order being from most recent to least recent vote-date
    data = data.filter(d => d.postId === postIdToFind);
    if (data.length > 0) { // apparently there can be multiple? or I'm just crazy?
      return data;
    }
    console.log(`nothing found in page ${pageNum+1}`);
    await (new Promise((resolve) => { setTimeout(resolve, millisBetweenRequests); }));
  }
  return null;
})());
console.log(data);

No SEDE, sadly, since voting data is anonymous (as it should be), and either I just can't read, or the API has no dice either.

1
  • ... comment upvotes? Commented Jan 1, 2025 at 12:56

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.