Skip to content

Instantly share code, notes, and snippets.

@CertainPerformance
Last active October 14, 2019 17:57
Show Gist options
  • Select an option

  • Save CertainPerformance/d16147600ffa63691e88116b5b040f1d to your computer and use it in GitHub Desktop.

Select an option

Save CertainPerformance/d16147600ffa63691e88116b5b040f1d to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name Stack Experiment Off
// @author CertainPerformance
// @description Turns off the voting experiment - shows true vote totals on pageload and after voting
// @description https://meta.stackoverflow.com/questions/390178/new-popup-message-when-voting-on-a-question
// @version 1.0.0
// @include /^https://stackoverflow\.com/questions/\d+/
// @run-at document-start
// @grant none
// ==/UserScript==
const nonNullObj = param => typeof param === 'object' && param !== null;
new MutationObserver((mutations, observer) => {
// Wait for window.StackExchange.init to be defined, which is done in stub.en.js near the top of the <head>
if (!window.StackExchange || !window.StackExchange.init) {
return;
}
observer.disconnect();
const origInit = window.StackExchange.init;
window.StackExchange.init = function(...args) {
if (nonNullObj(args[0]) && nonNullObj(args[0].site)) {
args[0].site.negativeVoteScoreFloor = -10000;
}
return origInit.apply(this, args);
};
// origInit is not just a plain function, it also has properties assigned to it
Object.assign(window.StackExchange.init, origInit);
})
.observe(document.documentElement, { childList: true, subtree: true });
window.addEventListener('DOMContentLoaded', () => {
[...document.querySelectorAll('.js-vote-count')]
.forEach((voteCountDiv) => {
if (voteCountDiv.dataset.value) {
voteCountDiv.textContent = voteCountDiv.dataset.value;
}
});
});
@JeffreyMercado
Copy link

Were you able to figure out how to have it apply to question lists, not just the questions themselves? I refuse to look at another 0 score question again.

@CertainPerformance
Copy link
Author

@JeffreyMercado Done. Fixing the question lists requires fetching vote counts from the API (unlike questions themselves, which have all information already available on the page)

@grantwinney
Copy link

grantwinney commented Oct 14, 2019

Thanks for this script. For anyone who can't find the setting, make sure you change "Config mode" to "Advanced" at the top of the settings page, to display the "Experimental" box at the bottom of the page, although it seems to work for me without it (Windows / Brave).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment