Skip to content

Instantly share code, notes, and snippets.

@Bhargav-Rao
Created May 29, 2017 21:01
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bhargav-Rao/09d923c0d90f193cd8f4d0fab71213c4 to your computer and use it in GitHub Desktop.
Save Bhargav-Rao/09d923c0d90f193cd8f4d0fab71213c4 to your computer and use it in GitHub Desktop.
@terdon
Copy link

terdon commented Jun 15, 2017

Fredley's great little script which autocompletes site names for the whois tool:

// ==UserScript==
// @name whois autocomplete
// @author fredley
// @description whois site mods
// @version 1.0
// @include http://chat.stackexchange.com/rooms/4/teachers-lounge
// @include https://chat.stackexchange.com/rooms/4/teachers-lounge
// @run-at document-end
// ==/UserScript==

var init = function($){
  var sites = [
    {
      'key': 'cm',
      'name': 'Community Managers',
      'icon': 'http://cdn.sstatic.net/stackexchange/img/apple-touch-icon.png'
    }
  ];
  var suggestions = [];
  var sugg_showing = false;
  var sugg_selected = -1;

  $(document).ready(function(){
    if(!localStorage['whois_sites']){
      $.ajax({
        url:'https://api.stackexchange.com/2.2/sites?pagesize=999',
        format:'json',
        success: function(data){
          data['items'].map(function(site){
            if(site['api_site_parameter'].substr(0,4) !== 'meta'){
              sites.push({
                'key': site['api_site_parameter'],
                'name': site['name'],
                'icon': site['icon_url']
              });
            }
          });
          console.log(sites.length + ' sites loaded');
          localStorage['whois_sites'] = JSON.stringify(sites);
        }
      });
    }else{
      sites = sites.concat(JSON.parse(localStorage['whois_sites']));
      console.log(sites.length + ' sites loaded from local storage');
    }

    $("#tabcomplete").after('<div id="whoiscomplete" style="text-align:left;"></div>');
    $("body").append('<style>#whoiscomplete li.chosen {box-shadow: 0 0 2px rgba(0, 0, 0, 0.8);border-color: #000;color: #FFF;background-color: #000;}#tabcomplete li *{vertical-align:middle;}#whoiscomplete li{display: inline-block;background-color: #FFF;color: #000;padding: 2px 5px 2px 2px;margin: 5px 5px 0 0;border: 1px solid #888;box-shadow: 0 0 2px rgba(0, 0, 0, 0.3);cursor: pointer;height: 18px;white-space: nowrap;}#whoiscomplete li img{margin-right: 3px;}</style>')

    var mod = function(m,n) {return ((m%n)+n)%n;};

    var render = function(){
      $('#whoiscomplete').html('');
      suggestions.map(function(s){
        $('#whoiscomplete').append('<li '+(s.selected ? 'class="chosen"' : '')+'><img width="18" height="18" src="'+s.icon+'"><span class="mention-name">'+s.name+'</span></li>');
        if(s.selected){
          var val = 'whois ' + s.key;
          if(s.key != 'cm') val += ' mods';
          $('#input').val(val);
        }
      });
    };
    $('#input').on('keydown',function(e){
      if(sugg_showing && e.keyCode === 9){
        e.preventDefault();
        suggestions[mod(sugg_selected,suggestions.length)]['selected'] = false;
        sugg_selected += (e.shiftKey) ? -1 : 1;
        suggestions[mod(sugg_selected,suggestions.length)]['selected'] = true;
        render();
        return;
      }else if(e.shiftKey){
        return;
      }
      sugg_selected = -1;
      var txt = $(this).val() + String.fromCharCode(e.keyCode);
      txt = txt.toLowerCase();
      if(e.keyCode === 8) txt = txt.substr(0,txt.length-2);
      if(txt.substr(0,6) === 'whois ' && txt.length > 6){
        var lookup = txt.substr(6);
        suggestions = [];
        sites.map(function(s){
          if(s.key.indexOf(lookup) === 0){
            s['selected'] = false;
            suggestions.push(s);
          }
        });
        if(suggestions.length > 0){
          sugg_showing = true;
          render();
        }else{
          sugg_showing = false;
          $('#whoiscomplete').html('');
        }
      }else if(sugg_showing){
        sugg_showing = false;
        $('#whoiscomplete').html('');
      }
    });
  });
}

var script = document.createElement('script');
script.type = 'text/javascript';
script.textContent = '(' + init.toString() + ')(jQuery)';
document.body.appendChild(script);

@Tanebi
Copy link

Tanebi commented Jun 16, 2017

@DavidPostill
Copy link

And another one:

Art's Mod Message Templates

@Glorfindel83
Copy link

I've just written a userscript to 'refresh' the flag queue automatically and send a desktop notification when there are new flags. It's available here.

@Bhargav-Rao
Copy link
Author

@fredley
Copy link

fredley commented Jan 30, 2018

There is some mod-specific stuff in Porkchat, my Chrome/FF extension. This includes:

  • editing deleted messages
  • autocomplete of sites in TL
  • editing permissions from within the room dropdown menu

@samliew
Copy link

samliew commented Apr 4, 2018

Comment Flags Helper

  • Highlights flagged user comments in expanded posts
  • Always expand comments if post is expanded
  • Highlight common chatty keywords

@rjrudman
Copy link

rjrudman commented Apr 9, 2018

Socky.

A dashboard for detecting sock puppets. Grabs users found in /admin/show-user-votes/ and lists them as a table for comparison.

Displays:

  • Users found in /admin/show-user-votes/
  • Previous names
  • PII (click to load)
  • Activity graph, with an easy way to bulk compare users
  • Reputation log
  • Warning if the 'voting ring' graph is detected

Dashboard looks like this: https://i.stack.imgur.com/Wx94M.png

Source can be found here in a private repository. If you'd like access, feel free to ping me, and I'll add you to the repo

@rjrudman
Copy link

rjrudman commented Apr 9, 2018

@rjrudman
Copy link

Link user ids referenced in CM invalidation response

// ==UserScript==
// @name         Links for invalidated
// @version      0.1
// @author       You
// @match        https://stackoverflow.com/admin/cm-message/*
// @grant        none
// ==/UserScript==

$(function() {
    const messageCode = $('tr.msg.msg-user pre > code');
    const messageCodeHtml = messageCode.html();
    const replaced = messageCodeHtml
    .replace(/(\d+) - (\d+)\: invalidated (\d+) votes/g, '<a href="/users/$1" target="_blank">$1</a> - <a href="/users/$2" target="_blank">$2</a>: invalidated $3 votes')
    .replace(/invalidated (\d+) votes from (\d+) to (\d+)/g, 'invalidated $1 votes from <a href="/users/$2" target="_blank">$2</a> to <a href="/users/$3" target="_blank">$3</a>');
    messageCode.html(replaced);
});

@samliew
Copy link

samliew commented Apr 12, 2018

Mod User Quicklinks Everywhere

  • Adds user moderation links sidebar with quicklinks & user details (from Mod Dashboard) to user-specific pages
  • Adds quicklinks to user infobox in posts

@Bhargav-Rao
Copy link
Author

Deprecated list - use https://stackoverflow.com/c/moderators/q/37/13 instead

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