Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // ==UserScript==
- // @name Improve Stack Overflow
- // @namespace http://tampermonkey.net/
- // @version 1.0
- // @description Helps Stack Overflow to be a more enjoyable website to use.
- // @author Blue Cow
- // @match https://stackoverflow.com/*
- // @grant none
- // ==/UserScript==
- var USER_ID = 100;
- function hide_annoying_page_elements() {
- 'use strict';
- // Hide the area about developer jobs.
- $("#nav-jobs").hide();
- // Hide the button for the review queues.
- $(".js-review-button").hide();
- // Modify the sidebar to behave better.
- hide_sidebar_distractions();
- // When the sidebar changes, run its mutator again.
- var mo = new MutationObserver(hide_sidebar_distractions);
- $("#sidebar").each(function() { mo.observe(this, {childList: true, subtree: true}); });
- }
- function hide_sidebar_distractions() {
- 'use strict';
- // Hide everything except the Ask Question button, statistics about the question, and linked questions.
- $("#sidebar > :not(.aside-cta,.question-stats,.sidebar-linked)").hide();
- }
- function prevent_reputation_loss() {
- 'use strict';
- // Prevent loosing reputation from downvoting.
- $(".vote-down-off").hide();
- // Prevent loosing reputation from making bounties.
- $(".bounty-link").hide();
- }
- function block_broken_elements() {
- 'use strict';
- // Block all imgur images since the proxy interferes.
- $("img[src*='i.stack.imgur.com']").hide();
- $("a[href*='i.stack.imgur.com']").hide();
- }
- function help_review_tag(tag_name) {
- 'use strict';
- var question_with_tag = $(`.post-taglist a[href='/questions/tagged/${tag_name}']`).length > 0;
- // Only help to review tags of tag_name.
- if (question_with_tag) {
- var pending_close_or_reopen = $(".existing-flag-count").length > 0;
- // Push through close or reopen votes if possible.
- if (pending_close_or_reopen) {
- $(".close-question-link:not([title^='You voted to '])").click();
- }
- var not_needed = pending_close_or_reopen || $("[title^='vote to reopen']").length > 0;
- var probably_duplicate = $("span.comment-copy:contains(Possible duplicate of)").length > 0;
- probably_duplicate = probably_duplicate || $(".question-originals-of-duplicate").length > 0;
- var question_by_me = $(`.question .user-details a[href^='/users/${USER_ID}/']`).length > 0;
- // Promote questions that have no negative signs if they are not my own.
- if ((!not_needed || probably_duplicate) && !question_by_me) {
- $(".question a.vote-up-off:not(.vote-up-on)").click();
- }
- var has_accepted_answer = $(".vote-accepted-on").length > 0;
- var answer_by_me = $(`.accepted-answer .user-details a[href^='/users/${USER_ID}/']`).length > 0;
- // Promote answers that appear to be correct if they are not my own.
- if (has_accepted_answer && !answer_by_me) {
- $(".accepted-answer a.vote-up-off:not(.vote-up-on)").click();
- }
- }
- }
- function change_background_colors(shift) {
- 'use strict';
- var white = 0xFF;
- var interesting = $(".tagged-interesting");
- var old_color = interesting.css("background-color").match(/^rgb\((\d+), (\d+), (\d+)\)$/).slice(1).map(x => parseInt(x));
- var new_color = "#" + old_color.map(x => (white - (white - x) * shift).toString(16).padStart(2, "0")).join("");
- interesting.css({"background-color": new_color});
- }
- (function() {
- 'use strict';
- hide_annoying_page_elements();
- prevent_reputation_loss();
- block_broken_elements();
- setTimeout(function() { change_background_colors(3); }, 500);
- setTimeout(function() { help_review_tag("python-3.x"); }, 1000);
- })();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement