|
|
(7 intermediate revisions by the same user not shown) |
Line 1: |
Line 1: |
| /* Any JavaScript here will be loaded for all users on every page load. */ | | /* Any JavaScript here will be loaded for all users on every page load. */ |
|
| |
| MMtoHuman(document.getElementsByClassName("micromorts"));
| |
|
| |
| function MMtoHuman ( elementArray ){
| |
| for (let span of elementArray){
| |
| if (span !== null){
| |
| let chance = 1000000 / parseInt(span.textContent);
| |
| let digits = Math.round(chance).toString().length;
| |
| let rounded = Math.round(chance / Math.pow(10, digits - 2)) * Math.pow(10, digits - 2);
| |
| span.textContent = "1 in " + rounded.toLocaleString();
| |
| }
| |
| }
| |
| }
| |
|
| |
| function getCookie(cookieName) {
| |
| const cookies = document.cookie.split('; ');
| |
| for (const cookie of cookies) {
| |
| const [name, value] = cookie.split('=');
| |
| if (name === cookieName) {
| |
| return decodeURIComponent(value);
| |
| }
| |
| }
| |
| return null;
| |
| }
| |
|
| |
| function deleteCookies(){
| |
| document.cookie = "userAge=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
| |
| document.cookie = "userGender=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
| |
| document.cookie = "userCountry=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
| |
| }
| |
| mw.loader.using('oojs-ui', function () {
| |
| let delCookies = new OO.ui.ButtonWidget( {
| |
| label: "Delete Cookies"
| |
| });
| |
| delCookies.on('click', function (){
| |
| deleteCookies();
| |
| delCookies.setIndicator('check');
| |
| });
| |
| $('.deleteCookies').replaceWith(delCookies.$element);
| |
| });
| |
Latest revision as of 21:52, 14 May 2025
/* Any JavaScript here will be loaded for all users on every page load. */