Aller au contenu

Utilisateur:Loveless/vector.js

Une page de Wikipédia, l'encyclopédie libre.
Note : après avoir enregistré la page, vous devrez forcer le rechargement complet du cache de votre navigateur pour voir les changements.

Mozilla / Firefox / Konqueror / Safari : maintenez la touche Majuscule (Shift) en cliquant sur le bouton Actualiser (Reload) ou pressez Maj-Ctrl-R (Cmd-R sur Apple Mac) ;

Firefox (sur GNU/Linux) / Chrome / Internet Explorer / Opera : maintenez la touche Ctrl en cliquant sur le bouton Actualiser ou pressez Ctrl-F5.
/* over 200k pages in watchlist, can't delete manually. 
Let's have fun with AJAX then.  */

//delete a single page. Sadly, it doesn't seems possible to just give page1|page2|page3, so gotta make one call for each.
function remove_page_from_watchlist(page_name) {
  var req = { 
      action: 'watch', 
      format: 'json', 
      title: page_name,
      unwatch: '',
      token: mw.user.tokens.get('watchToken')
  }
  $.ajax({ 
    type:'POST', dataType: 'json', 
    url: mw.util.wikiScript( 'api' ),
    data: req,
    timeout: 5000,
    success: function(resp){
      if( resp.error ) alert(resp.error.info)
      else if( !resp.watch ) alert('empty response')
      else if( typeof resp.watch.unwatched == 'string') true;
      else alert('unrecognized response')
    }
  })
  return false
}


function delete_watchlist() {
  //get a list of pages
  var req = { 
      format: 'xml', 
      action: 'query', 
      list: "watchlistraw",
      wrlimit: "200" //number of pages to get (limit 500 for user, 5k for bot/admins)
  }
  var pages = $.ajax({
    async: false,
    type:'GET', 
    dataType: 'xml', 
    url: mw.util.wikiScript( 'api' ),
    data: req,
    timeout: 5000,
   }).responseXML.documentElement.getElementsByTagName("wr")

   for (var a = 0, len = pages.length ; a < len ; a++) { 
       if( typeof( pages[a].attributes["title"] ) != 'undefined' ) {
           var page_name = pages[a].attributes["title"].value
           remove_page_from_watchlist(page_name)
       } 
   }
   return False
}

//addOnloadHook(delete_watchlist)