User:Bobogoobo/sandbox/Gadget-FileCleanup.js

//Other things to move here: // *non-animated images http://mlp.wikia.com/wiki/Category:Animated_images // *image size (needs a good bit of expansion for here) http://community.wikia.com/wiki/Thread:541511#4 // *I want to make something to help categorize videos. // *Could probably dig up some more stuff from my Python file, not sure how much could/should go here // *Maybe some of the stuff in my /wikia.js could go here as well //Ideas for overall functioning: // -maybe add an entry to MyTools that goes to Special:BlankPage, and with parameter present makes a thing for each script and runs them. Always run if elements are present.

//feel free to make suggestions for more to add, or to poke me to finish this! I really need not to give up.

//Script for User:Bobogoobo/Sources //TODO: redo this nasty code, ech // maybe use POST so I can do the whole category. // fix: sub-sub-categories (just use a dynamic list for all categories, would be much better) // will need ways to exclude certain images or types of images and such as well $(function {   if (! $('#missingsources').length) {       return;    }

// direct subcategories of Category:Images which need to be checked, keep alphabetized var categories = ['Animated images', 'Fanmade images', 'Merchandise images', 'Non-MLP images', 'Promotional images', 'Show production images']; var limit = '25'; //even 50 was too much, said the request string was too long

for (var i = 0; i < categories.length; i++) { var cat = categories[i].replace(/ /g, '_'), fpages = ''; $('#missingsources').append('Category:' +          categories[i] + ''); (function(thisCat, thisFpages) {       $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:' + thisCat + '&cmlimit=' + limit + '&format=json', function(data) { data = data.query.categorymembers; for (var j = 0; j < data.length; j++) { if (data[j].title === 'Category:IPony apps') { //skip this category } else if (data[j].ns === 14) { var cat2 = data[j].title.replace('Category:', '').replace(/ /g, '_'); $('#missingsources #' + thisCat).append('' +                      'Category:' +                       cat2.replace(/_/g, ' ') + ''); (function(thisCat2) {                   $.getJSON('/api.php?action=query&list=categorymembers&cmtitle=Category:' + thisCat2 + '&cmlimit=' + limit + '&format=json', function(response) { var pages = ''; response = response.query.categorymembers; for (var k = 0; k < response.length; k++) { pages += response[k].title; if (k !== response.length - 1) { pages += '|'; } }                       $.getJSON('/api.php?action=query&prop=revisions&titles=' +                           pages + '&rvprop=content&format=json', function(revs) {                            revs = revs.query.pages;                            for (var id in revs) {                                if (! revs[id].revisions) { continue; }                               var content = revs[id].revisions[0]['*'].toLowerCase;                                if ( content.indexOf('source]') + content.indexOf('{{source') + content.indexOf('source:') + content.indexOf('{{self}}') === -4 ) {                                   $('#missingsources #' + thisCat2).append('' + '' + revs[id].title + '');                               }                            }                        }); });                   }(cat2)); } else { thisFpages += data[j].title; if (j !== data.length - 1) { thisFpages += '|'; } }           }            $.getJSON('/api.php?action=query&prop=revisions&titles=' + thisFpages +               '&rvprop=content&format=json', function(revlist) {                //this block mostly copied from above because blah                revlist = revlist.query ? revlist.query.pages : [];                for (var pid in revlist) {                    //console.log(revlist[pid]);                    var pagecontent = revlist[pid].revisions[0]['*'].toLowerCase;                    if ( pagecontent.indexOf('source]') + pagecontent.indexOf('{{source') + pagecontent.indexOf('source:') + pagecontent.indexOf('{{self}}') === -4 ) {                       $('#missingsources #' + thisCat).append('' + '' + revlist[pid].title + '</a></li>');                   }                }            }); });       }(cat, fpages)); }

$('#missingsources').html('' + $('#missingsources').html + '</ol>'); });