Bruger:SimmeD/Scripts/massRollback.js
Udseende
< Bruger:SimmeD | Scripts
Bemærk, efter at have gemt, er du almindeligvis nødt til at tømme din browsers cache for at kunne se ændringerne.
Mozilla/Firefox/Safari/Konqueror: Hold shifttasten nede og klik på reload eller tryk på ctrl-shift-r
Internet Explorer: Ctrl-F5
Opera: F5
Safari til Mac: ⌥⌘E
Mozilla/Firefox/Safari/Konqueror: Hold shifttasten nede og klik på reload eller tryk på ctrl-shift-r
Internet Explorer: Ctrl-F5
Opera: F5
Safari til Mac: ⌥⌘E
//Mass rollback function
//Written by John254 and modified/rewritten by Writ Keeper with modifications by Writ Keeper (and SimmeD) (https://en.wikipedia.org/wiki/User:Writ_Keeper/Scripts/massRollback.js); original is at https://en.wikipedia.org/wiki/User:John254/mass_rollback.js
//Adapted from :enwiki:User:Mr.Z-man/rollbackSummary.js
//Instructions: Selecting the "rollback all" tab when viewing a user's contributions history
//will open all rollback links displayed there. (Use with caution)
if(typeof wkContribsCheckboxInit === "undefined")
{
wkContribsCheckboxInit = false;
}
if(typeof wkRollbackPortlet === "undefined")
{
wkRollbackPortlet = "p-cactions";
}
function rollbackEverythingWKMR(editSummary)
{
if(editSummary === null)
{
return false;
}
if(mw.config.get("wgRelevantUserName") === mw.config.get("wgUserName"))
{
if(!(confirm("Du er ved at tilbagerulle *alle dine egne* redigeringer. Bemærk venligst, at dette vil være meget svært at fortryde. Er du *HELT SIKKER* på, at du ønsker at gøre dette?")))
{
return false;
}
}
mw.loader.using( 'mediawiki.api' ).done( function()
{
var rbMetadata = {};
rbMetadata.api = new mw.Api();
rbMetadata.userName = mw.config.get("wgRelevantUserName");
rbMetadata.ipRange = (rbMetadata.userName === null);
rbMetadata.titleRegex = /title=([^&]+)/;
rbMetadata.editSummary = editSummary;
$("a[href*='action=rollback']").each(function(ind, el)
{
rollbackOneThingWKMR(el, rbMetadata);
} );
} );
return false;
}
function rollbackSomeThingsWKMR(editSummary)
{
if(editSummary === null)
{
return false;
}
mw.loader.using( 'mediawiki.api' ).done( function()
{
var rbMetadata = {};
rbMetadata.api = new mw.Api();
rbMetadata.userName = mw.config.get("wgRelevantUserName");
rbMetadata.titleRegex = /title=([^&]+)/;
rbMetadata.editSummary = editSummary;
var rollbackList = $("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']");
if(rollbackList.length <= 0)
{
mw.notify("Du har ikke valgt nogen redigeringer, der kan tilbagerulles!");
return;
}
$("input.revdelIds:checked").parents("li.mw-contributions-current").find("a[href*='action=rollback']").each(function(ind, el)
{
rollbackOneThingWKMR(el, rbMetadata);
} );
} );
}
function rollbackOneThingWKMR(edit, rbMetadata)
{
var userName;
//if we're in an anonymous IP range, we have to figure out each username on its own, since they might be different for each edit.
if(rbMetadata.userName === null)
{
//the not clause is probably not necessary, but I'm including it just to be sure.
userName = $(edit).parents("li:first").children("a.mw-anonuserlink").not(".mw-contributions-title").text();
}
else
{
userName = rbMetadata.userName;
}
var params = {};
if( rbMetadata.editSummary != '' )
{
params.summary = rbMetadata.editSummary;
}
rbMetadata.api.rollback( decodeURIComponent(rbMetadata.titleRegex.exec(edit.href)[1]), userName, params).done( function()
{
$(edit).after("reverted");
$(edit).remove();
} );
}
$(document).ready(function()
{
if(mw.config.get("wgCanonicalSpecialPageName") == "Contributions" && $("span.mw-rollback-link").length > 0)
{
mw.loader.using("mediawiki.util").done( function ()
{
mw.util.addPortletLink(wkRollbackPortlet, '#', "Tilbagerul alle", "ca-rollbackeverything", "tilbagerul alle viste redigeringer her");
if(!wkContribsCheckboxInit)
{
if($("ul.mw-contributions-list .mw-revdelundel-link").length > 0)
{
$("ul.mw-contributions-list .mw-revdelundel-link").each(function(ind,el){
if($(this).children("a").length > 0)
{
var revId = /ids=(\d+)/.exec($(this).children("a").attr("href"))[1];
var pageTitle = /target=([^&]+)/.exec($(this).children("a").attr("href"))[1];
$(el).prepend("<input type='checkbox' name='"+decodeURIComponent(pageTitle)+"' class='revdelIds' value='"+revId+"'> ");
$(el).children(".revdelIds").data("index", ind);
}
});
}
else
{
$("ul.mw-contributions-list a.mw-changeslist-date").each(function(ind,el){
$(el).before("<input type='checkbox' class='revdelIds'> ");
});
}
wkContribsCheckboxInit = true;
}
mw.util.addPortletLink(wkRollbackPortlet, '#', "Tilbagerul valgte", "ca-rollbacksome", "tilbagerul valgte redigeringer");
$("#ca-rollbackeverything").click( function(event)
{
event.preventDefault();
mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt
return rollbackEverythingWKMR(prompt("Tilbagerul alle redigeringer: Indtast en redigeringsbeskrivelse, eller lad feltet stå tomt for at bruge standardbeskrivelsen (eller tryk på Annuller for helt at afbryde tilbagerulningen)"));
});
$("#ca-rollbacksome").click( function(event)
{
event.preventDefault();
mw.loader.load( 'mediawiki.api' ); //start loading, while the user is in the prompt
return rollbackSomeThingsWKMR(prompt("Tilbagerul valgte redigeringer: Indtast en redigeringsbeskrivelse, eller lad feltet stå tomt for at bruge standardbeskrivelsen (eller tryk på Annuller for helt at afbryde tilbagerulningen)"));
});
$("#ca-rollbacksome").data("lastSelectedIndex", -1);
$("input.revdelIds").off("click").click(
function(ev)
{
var lastSelectedRevdel = $("#ca-rollbacksome").data("lastSelectedIndex");
var newIndex = $(this).data("index");
if(ev.shiftKey && lastSelectedRevdel >= 0)
{
var checkboxArray = $("input.revdelIds");
var start = lastSelectedRevdel;
var stop = newIndex;
if(start < stop)
{
for(var i = start; i < stop; i++)
{
if(i != lastSelectedRevdel)
{
$(checkboxArray[i]).prop("checked", !($(checkboxArray[i]).prop("checked")));
}
}
}
else
{
for(var i = start; i > stop; i--)
{
if(i != lastSelectedRevdel)
{
$(checkboxArray[i]).prop("checked", !($(checkboxArray[i]).prop("checked")));
}
}
}
}
$("#ca-rollbacksome").data("lastSelectedIndex", newIndex);
});
});
}
});