Lompat ke isi

Pengguna:Argo Carpathians/Peralatan/mass rollback.js: Perbedaan antara revisi

Dari Wikipedia bahasa Indonesia, ensiklopedia bebas
Konten dihapus Konten ditambahkan
kTidak ada ringkasan suntingan
Jon (WMF) (bicara | kontrib)
maintenance: more info Uncaught TypeError: Cannot read property 'indexOf' of undefined (links do not always have href)
Baris 8: Baris 8:


function rollbackEverything() {
function rollbackEverything() {
var link;
for (var i in document.links) {
for (var i in document.links) {
if (document.links[i].href.indexOf('action=rollback') != -1) {
link = document.links[i];
if (link && link.href && link.href.indexOf('action=rollback') != -1) {
window.open(document.links[i].href);
window.open(document.links[i].href);
}
}

Revisi per 10 Maret 2021 16.41

//Mass rollback function
//Written by John254
//Adapted from 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)

jQuery(document).ready(function ($) {

	function rollbackEverything() {
		var link;
		for (var i in document.links) {
			link = document.links[i];
			if (link && link.href && link.href.indexOf('action=rollback') != -1) {
				window.open(document.links[i].href);
			}
		}
	}

	function rollbackEverythingButton() {
		var hasRollback = $("span.mw-rollback-link");
		if (hasRollback[0] && (document.title.indexOf("Kontribusi pengguna") !== -1) ) {
			var link = mw.util.addPortletLink(
				'p-cactions',
				'#',
				'balikkan semua suntingan',
				'ca-rollbackeverything',
				'balikkan semua suntingan yang ditampilkan di sini'
			);
			$(link).click(function (e) {
				e.preventDefault();
				rollbackEverything();
			});
		}
	}

	mw.loader.using(['mediawiki.util'], function() {
		rollbackEverythingButton();
	});
});