User:Fox/copyvio.js

From Wikimedia Commons, the free media repository
(Redirected from User:Foxj/copyvio.js)
Jump to navigation Jump to search
Note: After saving, you have to bypass your browser's cache to see the changes. Internet Explorer: press Ctrl-F5, Mozilla: hold down Shift while clicking Reload (or press Ctrl-Shift-R), Opera/Konqueror: press F5, Safari: hold down Shift + Alt while clicking Reload, Chrome: hold down Shift while clicking Reload.
// Copyvio tagger
// Code by [[User:Animum]]

var UrlParameters = new Array ();
 
 function readparams() {
  var asReadInUrlParameters;
  var asReadInUrlParameter;
 
  // Get URL parameters
  asReadInUrlParameters = location.search.substring(1, location.search.length).split("&");
  for (i = 0; i < asReadInUrlParameters.length; i++) {
    asReadInUrlParameter = asReadInUrlParameters[i].split("=");
    UrlParameters[decodeURIComponent(asReadInUrlParameter[0])] = decodeURIComponent(asReadInUrlParameter[1]);
  }
 }
 
 readparams();
 
if(UrlParameters["action"] == "edit" && UrlParameters["copyviotag"] == 1) {
    addOnloadHook(function() {
        var req = sajax_init_object();
        req.open("GET", wgScriptPath + "/api.php?action=query&prop=revisions&titles=" + wgPageName + "&rvlimit=1&rvprop=user&rvdir=newer&format=json", false);
        req.send(null);
        var text = eval("(" + req.responseText + ")").query.pages;
        for(var index in text) {
            text = text[index];
            var user = text.revisions[0].user;
        }
        document.forms["editform"].wpTextbox1.value += '\{\{copyvio\}\}';
        document.forms["editform"].wpSummary.value = 'Tagging as a speedily deletable [[Commons:Licensing|copyright violation]] (using [[User:foxj/copyvio.js|copyvio]] script)';
        document.forms["editform"].wpMinoredit.checked = true;
        document.forms["editform"].submit();
        if(typeof(user) != 'undefined') window.setTimeout(function() { location.href = wgScript + "?title=User_talk:" + user + "&action=edit&copyvionotify=1&copyvio=" + wgPageName; }, 1000);
    });
}
 
if(UrlParameters["action"] == "edit" && UrlParameters["copyvionotify"] == 1 && UrlParameters["copyvio"].length > 0 && wgNamespaceNumber == 3) {
    addOnloadHook(function() {
        var copyvio = decodeURIComponent(UrlParameters["copyvio"].replace(/_/g, " "));
        document.forms["editform"].wpTextbox1.value += "\{\{subst:copyvionote|" + copyvio + "\}\} \~\~\~\~";
        document.forms["editform"].wpSummary.value = 'Notification - [[' + copyvio+ ']] is a probable [[Commons:Licensing|copyright violation]] (using [[User:foxj/copyvio.js|copyvio]] script)';
        document.forms["editform"].wpMinoredit.checked = true;
        document.forms["editform"].submit();
    });
}

$(function() {
    if(wgNamespaceNumber == 6 && !UrlParameters["copyviotag"]) mw.util.addPortletLink("p-cactions", wgScript + "?title=" + wgPageName + "&action=edit&copyviotag=1", "copyvio", "ca-copyvio");
});