4

This question already has an answer here:

I really liked the idea from Meta of highlighting the tags rather than the entire question - it was too overwhelming, so I created a userscript to do just this:

From:

Before view

To:

After view

(favorite tags are python, html, javascript in the pictures)

How it works?

It gets the favorite tags from the sidebar of the websites. Because the API doesn't allow us to get the favorite tags of a user, this means it will only work on pages where the sidebar is present (although I think all pages with question lists have the bar :).

Install

Tested on Google Chrome only, but I don't see why it shouldn't work on other userscript engines.

To install (on Chrome), download/save the file and drag into chrome://extensions. For other browsers, I have no idea ;p

I'd be happy for any feedback - I'm not a pro coder and there is definitely room for improvement :)

The code:

   // ==UserScript==
// @name         Interesting Questions alternate highlighting
// @namespace    http://stackexchange.com/users/4337810/%E1%B9%A7%D0%BD%CA%8A%C3%9F
// @version      0.2
// @description  Changes Stack Exchange websites 'favorite tags' highlighting to just the tag.
// @author       ṧнʊß
// @match        *://*.stackexchange.com/*
// @match        *://*.stackoverflow.com/*
// @match        *://*.superuser.com/*
// @match        *://*.serverfault.com/*
// @match        *://*.askubuntu.com/*
// @match        *://*.stackapps.com/*
// @match        *://*.mathoverflow.net/*
// @grant        none
// ==/UserScript==
var userscript = function($) {
    $(window).bind("load", function() {

        if (window.location.href.indexOf('superuser') > -1) { //superuser
            var betterCSS = {
                backgroundColor: '#a1eaff',
                color: 'black'                
            };
        }
        else if (window.location.href.indexOf('stackoverflow') > -1) { //stackoverflow
            var betterCSS = {
                backgroundColor: '#ffefc6',
                borderWidth: '0'                
            };
        }
        else if (window.location.href.indexOf('.stackexchange.com') > -1) {
            if (window.location.href.indexOf('meta') === -1) { //beta sites
                var betterCSS = {
                backgroundColor: '#c3dafa',
                borderWidth: '0'                
                }; 
            }
        }

        var x = $("#interestingTags").text();
        var interesting = x.split(' ');
        interesting.pop(); //Because there's one extra value at the end



        $(".tagged-interesting > .summary > .tags > .post-tag").filter(function(index) {
            return interesting.indexOf($(this).text()) > -1;
        }).css(betterCSS);

        $(".tagged-interesting").removeClass("tagged-interesting");
    });
};

var el = document.createElement('script');
el.type = 'text/javascript';
el.text = '(' + userscript + ')(jQuery);';
document.head.appendChild(el);

Change log

v. 0.2:

  • Added Stackoverflow, Superuser, Beta sites specific colours, to more match their colour scheme.

marked as duplicate by ᔕᖺᘎᕊ, Community Oct 2 '16 at 20:14

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

Browse other questions tagged .