User:OwenBlacker/Scripts/VoteSymbols.js

// Adapted largely from User:Ais523/votesymbols.js // Code for adding icons to !votes in AfDs, RfAs, etc.. Doesn't affect the page, just // shows the icons when this code is installed. // See individual images for their copyright status.

function lowerNoPunct(s) { return s.toLowerCase.replace(/[.,:;+]/g, ''); }

$(function { if ([0, 4].includes(mw.config.get('wgNamespaceNumber')))  {    // Avoid article space (0) and Wikipedia: space (4), generally speaking    return;  }

var iconSize = 21; // pixels

var voteIcons = [       '4/43/Stemicoon_voor.png/%%SIZE%%-Stemicoon_voor.png', '6/6d/Uitgevoerd.png/%%SIZE%%-Uitgevoerd.png', '6/62/Stemicoon_tegen.png/%%SIZE%%-Stemicoon_tegen.png', 'e/e5/Niet_uitgevoerd.png/%%SIZE%%-Niet_uitgevoerd.png', '2/28/Stemicoon_neutraal.png/%%SIZE%%-Stemicoon_neutraal.png', 'b/b0/Symbol_merge_vote.svg/%%SIZE%%-Symbol_merge_vote.svg.png', '4/4b/Bronvermelding_toolbar.png/%%SIZE%%-Bronvermelding_toolbar.png', '3/3f/Fairytale_key_enter-2.png/%%SIZE%%-Fairytale_key_enter-2.png', 'b/be/Wikt_rei-artur3.svg/%%SIZE%%-Wikt_rei-artur3.svg.png', 'b/be/Wikt_rei-artur3.svg/%%SIZE%%-Wikt_rei-artur3.svg.png', '6/6b/Pictogram_voting_empty_red.svg/%%SIZE%%-Pictogram_voting_empty_red.svg.png', '3/3d/Circle-question-blue.svg/%%SIZE%%-Circle-question-blue.svg.png', '8/8c/Znak_C-8.svg/%%SIZE%%-Znak_C-8.svg.png', '7/76/Pictogram_voting_wait_violet.svg/%%SIZE%%-Pictogram_voting_wait_violet.svg.png', '6/68/Emoticon_glad.svg/%%SIZE%%-Emoticon_glad.svg.png', 'd/dd/Bezig.png/%%SIZE%%-Bezig.png', '6/67/Blokkade.png/%%SIZE%%-Blokkade.png', ]; var votes = {     'support' : 0, 'endorse' : 0, 'keep' : 1, 'oppose' : 2, 'overturn' : 2, 'object' : 2, 'delete' : 3, 'neutral' : 4, 'merge' : 5, 'upmerge' : 5, 'move' : 6, 'rename' : 6, 'userfy' : 6, 'redirect' : 7, 'opinion' : 8, 'relist' : 8, 'subst' : 8, 'salt' : 8, 'change' : 8, 'list' : 8, 'comment' : 9, 'update' : 9, 'note' : 9, 'delist' : 10, 'question' : 11, 'split' : 12, 'wait' : 13, 'bjaodn' : 14, 'undelete' : 15, 'restore' : 15, 'close' : 16, };

var boldTags = document.body.getElementsByTagName("B"); boldTagsIndex = boldTags.length; while (boldTagsIndex--) {   var wordsToParse = boldTags[boldTagsIndex].innerHTML.split("<").join(" ").split(">") .join(" ").split("/").join(" ").split(" "); var word = 0; var imgToAdd = '';

while (word < wordsToParse.length) {     if ( lowerNoPunct(wordsToParse[word]) == "don't"        || lowerNoPunct(wordsToParse[word]) == 'not'        || lowerNoPunct(wordsToParse[word]) == 'no'        || lowerNoPunct(wordsToParse[word]) == 'without') {       break; }

var voteSymbolIndex = votes[lowerNoPunct(wordsToParse[word])]; if (voteSymbolIndex != undefined) {       imgToAdd += ' '; }     word++; }

if (imgToAdd != '') {     boldTags[boldTagsIndex].innerHTML = imgToAdd + boldTags[boldTagsIndex].innerHTML; } } }); //