Jump to content

User:Tenryuu/common.js

From Wikipedia, the free encyclopedia
Note: After saving, you have to bypass your browser's cache to see the changes. Google Chrome, Firefox, Microsoft Edge and Safari: Hold down the ⇧ Shift key and click the Reload toolbar button. For details and instructions about other browsers, see Wikipedia:Bypass your cache.
// install [[Wikipedia:User:Cacycle/wikEd]] in-browser text editor
(function ()
{
	var script = document.createElement('script');
	script.src = '//en.wikipedia.org/w/index.php?title=User:Cacycle/wikEd.js&action=raw&ctype=text/javascript';
	script.async = true;
	document.getElementsByTagName('head')[0].appendChild(script);
 }
) ();

// install word count script
mw.loader.load('//en.wikipedia.org/w/index.php?title=User%3ADr+pda%2Fprosesize.js&action=raw&ctype=text/javascript'); // [[User:Dr pda/prosesize.js]]


//voting
// [[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.
// Please see [[:Image:Votesymbols.js-enhanced_SfD.png]] for copyright info on the images that are added.

function lowerNoPunct(s)
{
  return s.toLowerCase().split('.').join('').split(',').join('').split(':').join('').split(';').join('').split('+').join('');
}

$(function() {
  if(mw.config.get('wgNamespaceNumber')===0) return; //avoid article space, generally speaking
  var vs=
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_support_vote.svg/20px-Symbol_support_vote.svg.png#"+
  //above is 0
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d0/Symbol_keep_vote.svg/20px-Symbol_keep_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_oppose_vote.svg/20px-Symbol_oppose_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/94/Symbol_delete_vote_Red.svg/20px-Symbol_delete_vote_Red.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_neutral_vote.svg/20px-Symbol_neutral_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/b0/Symbol_merge_vote.svg/20px-Symbol_merge_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/50/Symbol_move_vote.svg/20px-Symbol_move_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0c/Symbol_redirect_vote.svg/20px-Symbol_redirect_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/ba/Symbol_opinion_vote.svg/20px-Symbol_opinion_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/8c/Symbol_information_vote.svg/20px-Symbol_information_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f6/Symbol_unsupport_vote.svg/20px-Symbol_unsupport_vote.svg.png#"+
  //above is 10
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e0/Symbol_question.svg/20px-Symbol_question.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/0d/Symbol_split_vote.svg/20px-Symbol_split_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/5/54/Symbol_wait.svg/20px-Symbol_wait.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/b/bc/Face-grin.svg/20px-Face-grin.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f4/Symbol_userfy_vote.svg/20px-Symbol_userfy_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/3/3b/Symbol_no_support_vote.svg/20px-Symbol_no_support_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/4/41/Wikipedia_dislike.png/20px-Wikipedia_dislike.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/6/68/Wikipedia_like_SVG.svg/20px-Wikipedia_like_SVG.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/8/89/Symbol_remind_vote.svg/20px-Symbol_remind_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d7/Symbol_Translate.svg/20px-Symbol_Translate.svg.png#"+
  //above is 20
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/db/Symbol_list_class.svg/20px-Symbol_list_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/2/2a/Symbol_dab_class.svg/20px-Symbol_dab_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/6/61/Symbol_abstain_vote.svg/20px-Symbol_abstain_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/73/Symbol_lightbulb.svg/20px-Symbol_lightbulb.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/a/ae/Reload_icon.svg/20px-Reload_icon.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/74/Pictogram_voting_left_right_arrow.svg/20px-Pictogram_voting_left_right_arrow.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/3/3a/Symbol_point_of_order.svg/20px-Symbol_point_of_order.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/0/04/Symbol_wait_alternative.svg/20px-Symbol_wait_alternative.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/f/f7/Symbol_arrow_down.svg/20px-Symbol_arrow_down.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/2/28/Symbol_arrow_up.svg/20px-Symbol_arrow_up.svg.png#"+
  //above is 30
  "//upload.wikimedia.org/wikipedia/commons/thumb/c/ca/Symbol_possible_vote.svg/20px-Symbol_possible_vote.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/4/4d/Symbol_book_class.svg/20px-Symbol_book_class.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/e/e5/Symbol_version_newer.svg/20px-Symbol_version_newer.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/7/7f/Symbol_version_generic.svg/20px-Symbol_version_generic.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/4/4a/Symbol_vote_defer.svg/20px-Symbol_vote_defer.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/d3/Bouncing_Snowball.png/20px-Bouncing_Snowball.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/9/9b/Symbol_star_FA_gold.svg/20px-Symbol_star_FA_gold.svg.png#"+
  "//upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Symbol_Morden_vote.svg/20px-Symbol_Morden_vote.svg.png#"



  var vt=vs.split("#");
  var la=[];
  la['support']=0; la['endorse']=0; la['include']=0; la['yes']=0; la['agree']=0
  la['keep']=1; la['allow']=1; la['permit']=1; la['kept']=1
  la['oppose']=2; la['overturn']=2; la['object']=2; la['disallow']=2; la['exclude']=2; la['no']=2; la['disagree']=2; la['remove']=2 ; la['decline']
  la['delete']=3; la['deleting']=3; la['deleted']=3
  la['neutral']=4;
  la['merge']=5; la['upmerge']=5; la['merging']=5
  la['move']=6; la['userfy']=6; la['transwiki']=6; 
  la['redirect']=7; la['retarget']=7;
  la['opinion']=8; la['relist']=8; la['subst']=8; la['salt']=8; la['change']=8; la['list']=8;
  // Note that icon 8 on the list is often used for debate-specific !votes
  la['comment']=9; la['update']=9; la['note']=9; la['updated']=9
  la['delist']=10;
  la['question']=11;
  la['split']=12; la['set index']=12; la['SIA']=12;
  la['wait']=13; la['waiting']=13
  la['bjaodn']=14;
  la['convert']=15; la['change']=15
  la['close']=16;
  la['dislike']=17;
  la['like']=18;
  la['remind']=19; la['reminder']=19;
  la['rename']=20; la['translate']=20; la['renaming']=20; la['renamed']=20
  la['list']=21; la['listify']=21
  la['disambiguation']=22; la['disambiguate']=22; la['dab']=22; la['dabify']=22; la['disambig']=22
  la['abstain']=23; la['recuse']=23
  la['idea']=24; la['suggestion']=24
  la['revive']=25; la['restore']=25; la['undelete']=25; la['reviving']=25
  la['mixed']=26; la['ambivalent']=26; la['maybe']=26
  la['propose']=27; la['proposal']=27; la['proposition']=27; la['proposed']=27
  la['speedy']=28; la['speedily']=28
  la['weak']=29; la['demote']=29
  la['strong']=30; la['promote']=30
  la['conditional']=31
  la['reason']=32; la['rationale']=32
  la['lean']=33; la['leaning']=33; la['mostly']=33
  la['tentative']=34; la['tentatively']=34
  la['reverse']=35
  la['snow']=36
  la['verdict']=37; la['outcome']=37; la['result']=37
  la['ban']=38; la['blocked']=38

  var btc=document.body.getElementsByTagName("B");
  i=btc.length;
  while(i--)
  {
    var j,k;
    j=btc[i].innerHTML.split("<").join(" ").split(">").join(" ").split("/").join(" ").split(" ");
    k=0;
    var x="";
    while(k<j.length)
    {
      if(lowerNoPunct(j[k])=="don't"||lowerNoPunct(j[k])=='not'
       ||lowerNoPunct(j[k])=='without') break;
      var l=la[lowerNoPunct(j[k])];
      if(l!==undefined)
      {
        x+='<img src="'+vt[l]+'" alt="" /> '
      }
      k++;
    }
    if(x!=="") btc[i].innerHTML=x+btc[i].innerHTML;
  }
});


/* Toggle VF  */

// timestamp  10 Jun 2018  1603


var currpgName = mw.config.get( 'wgPageName' );
var currURL = document.location.href;
var prntable = currURL.endsWith("&printable=yes");
var torf = prntable.toString();
var myFlag;   // must be defined here
var currFlag;

function chkmyFlag() {
 
 	try{
    	currFlag=window.localStorage.getItem("myFlag"); 
 	} catch (e) {
 	}

    if (currFlag=="VF" && torf=="true")
    { 
    nullFlag();

    dotogg();
    
    }
}


chkmyFlag();

function nullFlag() {
	try {
		window.localStorage.setItem("myFlag", "null");
	} catch(e) {
	}
}
function setFlag()  {
	try {
		window.localStorage.setItem("myFlag", "VF");
	} catch (e) {
	}
}
function clrFlag()  {
	try {
		window.localStorage.clear();
	} catch(e){
	}
}

//  Printable VF Button

mw.loader.using( 'mediawiki.util', function () {
$( document ).ready( function() {
 
  var prntVF = mw.util.addPortletLink ( 'p-coll-print_export', 'https://en.wikipedia.org/w/index.php?title=' + currpgName + '&printable=yes', "Printable VF", "p-VF", "Voice-friendly version for printing [b]","b"); 	

    $( prntVF ).click( function() {
 			setFlag();
			});
	

    			});
});  	


// Toggle VF Button

var next="center";
mw.loader.using( 'mediawiki.util', function () {
$( document ).ready( function() {
	var ToggVF = mw.util.addPortletLink( "p-tb", "#", "Toggle VF", "t-Toggle VF","Convert to Voice-Friendly format[4]",'4');
// alert('next is: ' + next);
	$( ToggVF ).click( function() {
			dotogg();
     
		if (next=="center") {firstHeading.style.textAlign = "center";
    		$( ".Template-Fact" ).hide(); next="left"; }
	else
         {firstHeading.style.textAlign = "left";
			$( ".Template-Fact" ).show(); next="center";}
		    	 
	} );
} );

} );


// = = = = = = = = = = = = = = = = = = = = 

function dotogg()  {

$( 'head' ).append( '<style type="text/css" media="screen, print">' + ' ul { list-style: none; }' + '</style>' );

$( "wgCoordinates" ).toggle();
$( ".mw-headline[id='References'] " ).toggle();
$( ".mw-jump-link" ).toggle();
$( ".reference" ).toggle();
$( "ol.references" ).toggle();
$( ".toc" ).toggle();
$( ".template" ).toggle();
$( ".Template-Fact" ).hide();
$( ".collapsible" ).hide();
$( ".navbox" ).toggle();
$( ".navbar" ).toggle();
$( ".thumb" ).toggle();
$( ".wikitable" ).toggle();
$( ".toccolours" ).toggle();
$( ".hatnote" ).toggle();
$( ".hlist" ).toggle();
$( ".mw-headline[id='External_Links'] " ).toggle();
$( ".external" ).toggle();
//  $( ".external text").toggle();
//  $( ".external.text" ).show();  // showing only Ext Links

//
$( ".ambox" ).toggle();
$( ".mbox" ).toggle();
$( ".ombox" ).toggle();
$( ".dmbox" ).toggle();
$( ".fmbox" ).toggle();
$( ".geobox" ).toggle();
$( ".messagebox" ).toggle();
$( ".sidebar" ).toggle();
$( ".infobox" ).toggle();
$( ".infobox.sisterproject" ).toggle();
$( ".infobox.subdivision" ).toggle();
$( ".dablink" ).toggle();
$( ".metadata" ).toggle();
$( ".editlink" ).toggle();
//
$( "#siteSub" ).toggle();
$( ".printfooter" ).toggle();
$( "#catlinks, .catlinks" ).toggle();
$( "#footer" ).toggle(); 
$( "#header" ).toggle(); 
$( ".image" ).toggle();
$( ".metadata" ).toggle();
$( ".protected" ).toggle();
$( ".boilerplate" ).toggle();
$( ".mw-editsection-bracket" ).toggle();
$( ".mw-editsection" ).toggle();

}

// nowiki button for the 2017WTE
mw.loader.load('//en.wikipedia.org/w/index.php?title=User:Matma_Rex/nwe-nowiki.js&action=raw&ctype=text/javascript');
                    
//  ----------------------------------

//[[Category:Wikipedia scripts]]
importScript('User:DannyS712/DiscussionCloser.js'); // Backlink: [[User:DannyS712/DiscussionCloser.js]]
importScript('User:Jackmcbarn/editProtectedHelper.js'); // Backlink: [[User:Jackmcbarn/editProtectedHelper.js]]
mw.loader.load('https://wikiplus-app.com/Main.js');
importScript('User:RedWarn/.js'); // Backlink: [[User:RedWarn/.js]]
importScript('User:Galobtter/scripts/adminhighlighter.js'); // Backlink: [[User:Galobtter/scripts/adminhighlighter.js]]
importScript('User:SD0001/W-Ping.js'); // Backlink: [[User:SD0001/W-Ping.js]]
importScript('Wikipedia:AutoEd/complete.js');
importScript('User:Technical_13/Scripts/OneClickArchiver.js'); // Backlink: [[User:Technical_13/Scripts/OneClickArchiver.js]]
importScript('User:Enterprisey/diff-permalink.js'); // Backlink: [[User:Enterprisey/diff-permalink.js]]
importScript('User:BrandonXLF/ShowRevisionID.js'); // Backlink: [[User:BrandonXLF/ShowRevisionID.js]]
importScript('User:Rublov/diff-link.js'); // Backlink: [[User:Rublov/diff-link.js]]
importScript('User:DannyS712/SATG.js'); // Backlink: [[User:DannyS712/SATG.js]]
importScript('User:SuperHamster/CiteUnseen.js'); // Backlink: [[User:SuperHamster/CiteUnseen.js]]