Last active
October 14, 2019 17:57
-
-
Save CertainPerformance/d16147600ffa63691e88116b5b040f1d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==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; | |
| } | |
| }); | |
| }); |
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)
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
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.