User:JJPMaster/CurateThisPage2/wikilove.js

From Uncyclopedia, the content-free encyclopedia
Jump to navigation Jump to search

Note: After saving, you have to bypass your browser's cache to see the changes.

  • Internet Explorer: hold down the Ctrl key and click the Refresh or Reload button, or press Ctrl+F5.
  • Firefox: hold down the Shift key while clicking Reload; alternatively press Ctrl+F5 or Ctrl-Shift-R.
  • Opera, Konqueror and Safari users can just click the Reload button.
  • Chrome: press Ctrl+F5 or Shift+F5
var url = "https://en.uncyclopedia.co/w/api.php";

var params = {
    action: "query",
    prop: "revisions",
    titles: wgPageName,
    rvprop: "timestamp|user|comment|content",
    rvslots: "main",
    formatversion: "2",
    format: "json"
};

url = url + "?origin=*";
Object.keys(params).forEach(function(key){url += "&" + key + "=" + params[key];});

fetch(url)
    .then(function(response){return response.json();})
    .then(function(response) {
        var pages = response.query.pages;
        for (var p in pages) {
            console.log(pages[p].revisions);
        }
    })
    .catch(function(error){console.log(error);});