chylex - software development and game modding projects

Your browser is garbage, update it.

Custom Browser Scripts

Here are a couple scripts you can run in your browser console, or add to your bookmarks. Many of these use JavaScript syntax and features that may not be supported in old and bad browsers. They have been written in such a way as to minimize their size while keeping them at least somewhat readable, and to abuse many quirks of the language. All uglification was done manually.

Scripts that have a response will print it into the browser console, even if you use a bookmark. You can open it by pressing F12 in most browsers and making sure the Console tab is selected.

YouTube

Load all videos in a playlist [Bookmark]

Caution: This will infinitely load any page that has a 'Load more' button, which also includes the 'My subscriptions' page and others.

window.setInterval(() => {
  var ele = document.getElementsByClassName("load-more-button");
  !ele.length || ele[0].click()
}, 500);

Calculate total playlist time [Bookmark]

Only includes videos that are visible on the page. If a playlist has many videos, use the previous script to load the entire list first.

var seconds = [].reduce.call(document.querySelectorAll("#pl-video-table .timestamp span"), (total, ele) => total+ele.innerHTML.split(":").reduce((prev, cur, index, arr) => prev+parseInt(cur, 10)*Math.pow(60, arr.length-index-1), 0), 0), minutes, hours, days;

seconds -= (minutes = Math.floor(seconds/60))*60;
minutes -= (hours = Math.floor(minutes/60))*60;
hours -= (days = Math.floor(hours/24))*24;

console.info([[ days, "day" ], [ hours, "hour" ], [ minutes, "minute" ], [ seconds, "second" ]].map(arr => [ arr[0], " ", arr[1], (arr[0] === 1 ? "" : "s") ].join("")).join(", "));

MediaWiki

Recent Changes statistics [Bookmark]

If you want to display full history in your Recent Changes:
1. Open LocalSettings.php and add $wgRCMaxAge = 777600000; at the end to disable automatic purge every 3 months (this will keep it for ~24.6 years)
2. Open includes/specials/SpecialRecentchanges.php, find validateOptions, and replace the 5000 on the next line with 500000 to increase the display limit
3. Execute php maintenance/rebuildrecentchanges.php to regenerate the page
4. Go to Recent Changes page in your wiki and append ?days=9999&limit=500000 to the URL

var printEntry = entry => {
  var hasDay = entry.title[0] >= '0' && entry.title[0] <= '9';

  console.info([
    (entry.title[1] === " " ? entry.title = " "+entry.title : entry.title),
    " ".repeat(Math.max(2, (hasDay ? 19 : 16)-entry.title.length)),
    "+", entry.data[0],
    " ".repeat(Math.max(2, (hasDay ? 7 : 8)-entry.data[0].toString().length)),
    "-", entry.data[1]
  ].join(""));
};

var res = ((main, mwClasses, table) => {
  for(var ind = 0; ind < main.length; ind += 2){
    table.push({
      title: main[ind].innerHTML,
      data: mwClasses.map(cl => [].slice.call(main[ind+1].getElementsByClassName(cl))
        .filter(ele => ele.offsetParent === null || ele.parentNode.previousSibling.previousSibling === null)
        .reduce((prev, ele) => prev+parseInt(ele.innerHTML.replace(/\D/g, ""), 10), 0))
    });
  }

  return table;
})(document.getElementsByClassName("mw-changeslist")[0].children, [ "mw-plusminus-pos", "mw-plusminus-neg" ], []);

console.info("== PER DAY STATISTICS ==");

res.reverse().forEach(printEntry);

console.info("== PER MONTH STATISTICS ==");

(conv => Object.keys(conv).sort().map(key => conv[key]).forEach(printEntry))(res.reduce((obj, ele) => {
  var title = ele.title.substring(2).trim();
  var key = +Date.parse("1 "+title);

  if (key in obj){
    ele.data.forEach((val, index) => obj[key].data[index] += val);
  }
  else{
    obj[key] = { title: title, data: ele.data.slice() };
  }

  return obj;
}, {}));

console.info("== OVERALL STATISTICS ==");

(args => console.info([ "+", args[0], "   -", args[1] ].join("")))([ 0, 1 ].map(ind => res.reduce((prev, cur) => prev+cur.data[ind], 0)));