MediaWiki:SlayerPointsCalc.js
Note: After publishing, you may have to bypass your browser's cache to see the changes.
- Firefox / Safari: Hold Shift while clicking Reload, or press either Ctrl-F5 or Ctrl-R (⌘-R on a Mac)
- Google Chrome: Press Ctrl-Shift-R (⌘-Shift-R on a Mac)
- Internet Explorer / Edge: Hold Ctrl while clicking Refresh, or press Ctrl-F5
- Opera: Press Ctrl-F5.
mw.hook('wikipage.content').add(function () {
// Only run on the correct page
if (mw.config.get('wgPageName') !== "Slayer_points_calculator") return;
var container = document.getElementById("slayerCalcContainer");
if (!container) return;
// Build UI
container.innerHTML =
'<div style="margin-bottom:10px;">' +
'Donator Boost: ' +
'<select id="donatorBoost">' +
'<option value="0">None</option>' +
'<option value="5">Donator (+5%)</option>' +
'<option value="10">Super Donator (+10%)</option>' +
'<option value="15">Extreme Donator (+15%)</option>' +
'<option value="25">Legendary Donator (+25%)</option>' +
'<option value="50">Royal Donator (+50%)</option>' +
'<option value="75">Divine Donator (+75%)</option>' +
'</select>' +
'</div>' +
// Slayer Gatherer checkbox
'<div style="margin-bottom:10px;">' +
'<label>' +
'<input type="checkbox" id="slayerGatherer"> Slayer Gatherer (+50% points per task)' +
'</label>' +
'</div>' +
'<table id="slayerTable" style="border-collapse:collapse; width:400px;">' +
'<thead>' +
'<tr style="background:#222e45;color:#fff;">' +
'<th style="padding:5px;text-align:left;">Task</th>' +
'<th style="padding:5px;text-align:center;">Points</th>' +
'</tr>' +
'</thead>' +
'<tbody></tbody>' +
'</table>' +
// Max Cape info note
'<div style="margin-top:10px; font-size:90%; color:#ccc;">' +
'Note: The Max Cape perk gives a 20% chance to double Slayer Points. This calculator does not include it in the totals.' +
'</div>';
var basePoints = 25;
var milestones = [
{name:"Normal task", multiplier:1},
{name:"10th task", multiplier:5},
{name:"50th task", multiplier:15},
{name:"100th task", multiplier:25},
{name:"250th task", multiplier:35},
{name:"1,000th task", multiplier:50}
];
var tbody = document.querySelector("#slayerTable tbody");
milestones.forEach(function(milestone, index){
var row = tbody.insertRow();
row.style.background = index % 2 ? "#222e45" : "#313e59";
row.style.color = "#fff";
var cell1 = row.insertCell();
cell1.textContent = milestone.name;
cell1.style.padding = "5px";
var cell2 = row.insertCell();
cell2.id = "points_" + index;
cell2.style.textAlign = "center";
cell2.style.padding = "5px";
});
function updatePoints() {
var boost = parseFloat(document.getElementById("donatorBoost").value) || 0;
var multiplierBoost = 1 + boost/100;
var gatherer = document.getElementById("slayerGatherer").checked ? 0.5 : 0;
milestones.forEach(function(milestone, index){
var points = basePoints * milestone.multiplier * multiplierBoost * (1 + gatherer);
document.getElementById("points_" + index).textContent = Math.floor(points);
});
}
// Event listeners
document.getElementById("donatorBoost").addEventListener("change", updatePoints);
document.getElementById("slayerGatherer").addEventListener("change", updatePoints);
updatePoints();
});