// This is a very simple script. Basically, what it does is add buttons to "contributions" pages, like Special:Contributions/JPxG or Special:MyContributions, which allow you to toggle displaying current contributions.
// It's useful if you participate in a lot of discussions, and you want to see which of them have been responded to (i.e. which of your comments are no longer the current revision).
// - JPxG, 2021 08 24
$( function() {
if( (window.location.href.indexOf( "Special:Contributions/" ) >= 0 ) || (window.location.href.indexOf( "Special%3AContributions" ) >= 0 )) {
crct = document.querySelectorAll('.mw-contributions-current').length;
// Count the number of "current"s
rbct = document.querySelectorAll('.mw-tag-mw-rollback').length;
// Count the number of "rollback"s
hgct = document.querySelectorAll('.mw-tag-huggle').length;
// Count the number of "huggle"s
dpct = 0;
titles=[];
allcount = document.getElementsByTagName('li');
// We are going to count all the dupes now.
for(var asdf in allcount){
try{
var title = allcount[asdf].getElementsByClassName('mw-contributions-title')[0].innerHTML;
//$('.mw-pager-navigation-bar').append(allcount[asdf]);
if (titles.includes(title)) {
dpct = dpct + 1;
}
titles.push(title);
//alert(String(titles));
} catch(e) {console.log(e)}
}
$('.mw-pager-navigation-bar').append(' Toggle: <button type="button" id="currentrevs" class="crbutton"><small><small>current<br />'+crct+'</small></small></button>');
$('.mw-pager-navigation-bar').append(' <button type="button" id="rollback" class="rbbutton"><small><small>rollback<br /> '+rbct+'</small></small></button>');
$('.mw-pager-navigation-bar').append(' <button type="button" id="huggle" class="hgbutton"><small><small>huggle<br />'+hgct+'</small></small></button>');
$('.mw-pager-navigation-bar').append(' <button type="button" id="dupes" class="dpbutton"><small><small>dupes<br />'+dpct+'</small></small></button>');
document.getElementById("currentrevs").style = "font-family: monospace; padding: 1px; border: 3px; width=8em";
document.getElementById("rollback").style = "font-family: monospace; padding: 1px; border: 3px; width=8em";
document.getElementById("huggle").style = "font-family: monospace; padding: 1px; border: 3px; width=8em";
document.getElementById("dupes").style = "font-family: monospace; padding: 1px; border: 3px; width=8em";
// Add the buttons.
var currenthidden = 0;
var rollbackhidden = 0;
var hugglehidden = 0;
var dupeshidden = 0;
// Set toggle variables.
$('#currentrevs').click(function(e) {
// Listener for "what to do if the 'current' button is clicked"
if(currenthidden == 0){
$( '.mw-contributions-current' ).hide()
// Hide the diffs.
x = document.getElementsByClassName('crbutton')[0]
x.innerHTML = "<strike><small><small>current<br />"+crct+"</small></small></strike>"
// Strike out the text on the button.
} // If toggle is 0, hide them.
if(currenthidden == 1){
$( '.mw-contributions-current' ).show();
// Show the diffs.
x = document.getElementsByClassName('crbutton')[0]
x.innerHTML = "<small><small>current<br />"+crct+"</small></small>"
// Unstrike the text on the button.
} // If toggle is 1, show them.
currenthidden = (1 - currenthidden);
// Either way, invert the toggle.
});
$('#rollback').click(function(e) {
// Listener for "what to do if the 'rollback' button is clicked"
if(rollbackhidden == 0){
$( '.mw-tag-mw-rollback' ).hide();
// Hide the diffs.
x = document.getElementsByClassName('rbbutton')[0]
x.innerHTML = "<strike><small><small>rollback<br /> "+rbct+"</small></small></strike>"
// Strike out the text on the button.
} // If toggle is 0, hide them.
if(rollbackhidden == 1){
$( '.mw-tag-mw-rollback' ).show();
// Show the diffs.
x = document.getElementsByClassName('rbbutton')[0]
x.innerHTML = "<small><small>rollback<br /> "+rbct+"</small></small>"
// Unstrike the text on the button.
} // If toggle is 1, show them.
rollbackhidden = (1 - rollbackhidden);
// Either way, invert the toggle.
});
$('#huggle').click(function(e) {
// Listener for "what to do if the 'huggle' button is clicked"
if(hugglehidden == 0){
$( '.mw-tag-huggle' ).hide();
// Hide the diffs.
x = document.getElementsByClassName('hgbutton')[0]
x.innerHTML = "<strike><small><small>huggle<br />"+hgct+"</small></small></strike>"
// Strike out the text on the button.
} // If toggle is 0, hide them.
if(hugglehidden == 1){
$( '.mw-tag-huggle' ).show();
// Show the diffs.
x = document.getElementsByClassName('hgbutton')[0]
x.innerHTML = "<small><small>huggle<br />"+hgct+"</small></small>"
// Unstrike the text on the button.
} // If toggle is 1, show them.
hugglehidden = (1 - hugglehidden);
// Either way, invert the toggle.
});
$('#dupes').click(function(e) {
// Listener for "what to do if the 'dupes' button is clicked"
if(dupeshidden == 0){
titles=[];
allcount = document.getElementsByTagName('li');
// We are going to count all the dupes now.
for(var asdf in allcount){
try{
var title = allcount[asdf].getElementsByClassName('mw-contributions-title')[0].innerHTML;
//$('.mw-pager-navigation-bar').append(allcount[asdf]);
if (titles.includes(title)) {
allcount[asdf].style.visibility = "hidden";
}
titles.push(title);
} catch(e) {console.log(e)}
}
// Hide the diffs.
x = document.getElementsByClassName('dpbutton')[0]
x.innerHTML = "<strike><small><small>dupes<br />"+dpct+"</small></small></strike>"
// Strike out the text on the button.
} // If toggle is 0, hide them.
if(dupeshidden == 1){
allcount = document.getElementsByTagName('li');
// We are going to count all the dupes now.
for(var asdf in allcount){
try{
var title = allcount[asdf].getElementsByClassName('mw-contributions-title')[0].innerHTML;
//$('.mw-pager-navigation-bar').append(allcount[asdf]);
if (titles.includes(title)) {
allcount[asdf].style.visibility = "visible";
}
titles.push(title);
} catch(e) {console.log(e)}
}
// Hide the diffs.
// Show the diffs.
x = document.getElementsByClassName('dpbutton')[0]
x.innerHTML = "<small><small>dupes<br />"+dpct+"</small></small>"
// Unstrike the text on the button.
} // If toggle is 1, show them.
dupeshidden = (1 - dupeshidden);
// Either way, invert the toggle.
});
}
} );