Suradnik:Ivi104/Skripte/Neophođene-promjene-u-doprinosima.js: razlika između inačica
< Suradnik:Ivi104 | Skripte
Izbrisani sadržaj Dodani sadržaj
m -log |
m +neophođene promjene u povijesti stranice |
||
Redak 1: | Redak 1: | ||
$(document).ready(function() { |
$(document).ready(function() { |
||
⚫ | |||
⚫ | |||
⚫ | |||
if (location.search.includes('action=history')) { |
|||
⚫ | |||
if (mw.config.get("wgPageName")) { |
|||
console.log("imam ime stranice!"); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
} else { |
|||
console.log("na doprinosima smo!"); |
|||
⚫ | |||
⚫ | |||
apirequest = "/api.php?action=query&format=json&prop=info&list=recentchanges&inprop=&rcuser=" + mw.config.get("wgRelevantUserName") + "&rcprop=ids%7Cpatrolled&rclimit=200"; |
|||
//console.log("doprinosi - req: " + apirequest); |
|||
} |
|||
} |
|||
//console.log("main - req: " + apirequest); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
//console.log("unpatrolled revid " + entry.revid); |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
var unpatrolledMarker = document.createElement('abbr'); |
var unpatrolledMarker = document.createElement('abbr'); |
||
unpatrolledMarker.className = 'unpatrolled'; |
|||
unpatrolledMarker.title = 'Nepregledana izmjena'; |
|||
unpatrolledMarker.innerHTML = '!'; |
|||
unpatrolledMarker.style.display = 'inline'; |
|||
unpatrolledMarker.style.padding = '10px'; |
|||
items[i].prepend(unpatrolledMarker); |
items[i].prepend(unpatrolledMarker); |
||
} |
|||
} |
} |
||
} |
} |
||
} |
}); |
||
}); |
}); |
||
} // if povijest or doprinosi |
|||
} //if not null |
|||
} //if pregled doprinosa |
|||
}); |
}); |
Inačica od 14. rujna 2020. u 13:50
$(document).ready(function() {
if (location.search.includes('title=Posebno%3ADoprinosi') ||
location.href.includes('Special:Contributions') || location.href.includes('Posebno:Doprinosi') || location.href.includes('Posebno%3ADoprinosi') || location.search.includes('action=history')) {
var apirequest = "";
if (location.search.includes('action=history')) {
console.log("Na povijesti smo!");
if (mw.config.get("wgPageName")) {
console.log("imam ime stranice!");
apirequest = "/api.php?action=query&format=json&prop=info&list=recentchanges&inprop=&rctitle=" + mw.config.get("wgPageName") + "&rcprop=ids%7Cpatrolled&rclimit=200";
//console.log("povijest - req: " + apirequest);
}
} else {
console.log("na doprinosima smo!");
if (mw.config.get("wgRelevantUserName")) { //not null or undefined
console.log("Imam username!");
apirequest = "/api.php?action=query&format=json&prop=info&list=recentchanges&inprop=&rcuser=" + mw.config.get("wgRelevantUserName") + "&rcprop=ids%7Cpatrolled&rclimit=200";
//console.log("doprinosi - req: " + apirequest);
}
}
//console.log("main - req: " + apirequest);
api = $.getJSON(mw.config.get("wgScriptPath") + apirequest)
.done(function(query) {
if (!query.query) { console.log("API fail"); return; } // API fail
query = query.query;
query.recentchanges.forEach(function(entry) {
if (entry.unpatrolled === "") {
items = document.querySelectorAll('li[data-mw-revid]');
for (var i = 0; i < items.length; i++) {
if (items[i].getAttribute('data-mw-revid') == entry.revid) {
//console.log("unpatrolled revid " + entry.revid);
var unpatrolledMarker = document.createElement('abbr');
unpatrolledMarker.className = 'unpatrolled';
unpatrolledMarker.title = 'Nepregledana izmjena';
unpatrolledMarker.innerHTML = '!';
unpatrolledMarker.style.display = 'inline';
unpatrolledMarker.style.padding = '10px';
items[i].prepend(unpatrolledMarker);
}
}
}
});
});
} // if povijest or doprinosi
});