Fandom

Wikia Developers Wiki

HighlightUsers using auto-generated CSS

  • HighlightUsers has been unmaintained for over 2 years. Several issues user have suggested have not been fixed.

    Here I suggest a few changes:

    • Use auto-generated CSS instead of adding color to elements one by one. - Using Ajax to color elements is slow and elements loaded after the script are not colored. CSS stylesheet ensures all matched elements are colored whenever they are loaded.
      • Neither $(document).ready(); nor $(window).load(): is able to solve this problem.
    • Use caches to save loading time. (You don't want to generate the same stylesheet every time you load a page, right?)
    • Detect user rights changes so that the stylesheets are updated once there are any changes.
    • Suggested by mfaizsyahmi and leviathan_89: Give each user group a specific class.
    • Exclude links in "My favorite wikis".
    • Update: Load from the cached stylesheet after the stylesheet has been generated.
      Loading editor
    • Agreed with using a stylesheet, and caching said stylesheet. Perhaps caching can be done with localStorage, and fall back to cookies. That said, I tend to use one or the other but not both, supporting both bloats the code and makes it harder to maintain IMO.

      I'm not sure how to properly do "detect user rights changes" without making AJAX calls on every page load.

      Adding user group classes is the natural step forward IMO.

        Loading editor
    • Working on it.

        Loading editor
    • Colouratura wrote: Working on it.

      Thanks. ;)

        Loading editor
    • Cqm

      Probably the easiest thing is to make a js script that queries the API for a set list of groups which can regenerate the css as required. The API call would be something like http://dev.wikia.com/api.php?action=query&list=allusers&augroup=vanguard&aulimit=max&format=jsonfm (in this case I've used vanguard) and in rough terms of code it would end up with something like the following:

      var groups = [
              'vanguard',
              'voldev',
              'vstf',
              'helper',
              'staff'
          ];
          users = {};
      
      function generateCSS() {
          // generate css here and add to the css page
      }
      
      function getUsers(i) {}
          group = groups[i];
          // get list of users
          (new mw.Api()).get({
              // params go here, including group name
          }).done(function (res) {
              // access list of users from api result
              users[group[i]] = listOfUsers;
              if ([i + 1 === group.length) { generateCSS(); return; }
              getUsers(i + 1);
          })
      });
      

      Things to remember include handling needing to re-query the api if the list of users isn't in a single set of results, encoding certain user names for older browsers and not deleting the list of bots current in the stylesheet.

        Loading editor
    • A Fandom user
        Loading editor
Give Kudos to this message
You've given this message Kudos!
See who gave Kudos to this message

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.