// ==UserScript==
// @name [MR] Popmundo Utilities
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Some gameplay improvements and shorcuts for popmundo.
// @author Serhat Yücel A.K.A Matt Revolve (1736266)
// @match https://*.popmundo.com/*
// @require https://code.jquery.com/jquery-3.5.1.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js
// @require https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/js/all.min.js
// @downloadURL https://update.greasyfork.icu/scripts/430424/%5BMR%5D%20Popmundo%20Utilities.user.js
// @updateURL https://update.greasyfork.icu/scripts/430424/%5BMR%5D%20Popmundo%20Utilities.meta.js
// ==/UserScript==
(function() {
'use strict';
const url = window.location.href;
const orig = window.location.origin;
progressBarPercentages();
controlPhoneCall();
const blocked_char_list = ["3513487"];
if(url.includes("/Locale/ItemsEquipment")){
showHideOnlyYourItemsPrepare();
}else if(url.includes("/Interact/Phone")) {
//mobilePhoneCallAutoChosenCombo();
}else if(url.includes("/Character/OfferItem")) {
hideOfferedItem();
}else if(url.includes("/City") && $("#ctl00_cphLeftColumn_ctl00_lnkAirport").length > 0) {
addCityShortcuts();
}else if(url.includes("/Character/Relations/") && $("#mnuToolTipImproveCharacter").length != 0) {
//relationLinkToPhoneCall();
makePhoneCalls();
}else if(url.includes("/Character/Diary/")) {
//countKilledZombies();
}else if(url.includes("/Character/Items")) {
inventoryUtility();
}else if(url.includes("/Forum/Popmundo.aspx/Thread/")) {
bbcodeGenerator();
}
function bbcodeGenerator() {
$(".forumMessageHeader a:first-child").each(function() {
const charName = $(this).text().trim();
const charid = $(this).attr("href").split("/").slice(-1)[0].trim();
$(this).before(`
`);
//$(this).before(`
`);
});
$(".mr_bbcode").on('click',function() {
const str = $(this).attr("data");
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
el.select();
document.execCommand('copy');
document.body.removeChild(el);
});
}
function inventoryUtility() {
if($("#ctl00_cphLeftColumn_ctl00_chkThrowAwaySelItems").length > 0) {
$("#ctl00_cphLeftColumn_ctl00_chkThrowAwaySelItems").click();
}
}
function countKilledZombies() {
var zombieCount = 0;
$(".diaryExtraspace li").each(function() {
let diaryText = $(this).text().trim();
if(diaryText.length < 100) {
if(diaryText.includes("zombiyi cehenneme geri gönderdim!")){
console.log(diaryText);
diaryText = diaryText.replace(" zombiyi cehenneme geri gönderdim!","").trim();
diaryText = diaryText.replace("BOOM! El bombasıyla ","").trim();
zombieCount += parseInt(diaryText.trim());
}else if(diaryText.includes("Stormswinger enerjimi biraz tazeledi")) {
console.log(diaryText);
diaryText = diaryText.replace("Stormswinger enerjimi biraz tazeledi ve ","");
diaryText = diaryText.replace(" zombiyi katletmemden memnun görünüyor.","");
zombieCount += parseInt(diaryText.trim());
}
}
});
console.log(zombieCount);
}
function showHideOnlyYourItemsPrepare() {
if(localStorage.getItem("ONLY_YOUR_ITEMS") == null) {
localStorage.setItem("ONLY_YOUR_ITEMS", 0);
}
$("#checkedlist").before('Alınabilecek Eşyaları Göster/Gizle');
showHideOnlyYourItems();
$("#showHideOnlyYourItems").on('click', function() {
if(localStorage.getItem("ONLY_YOUR_ITEMS") == 1){
localStorage.setItem("ONLY_YOUR_ITEMS", 0);
}else {
localStorage.setItem("ONLY_YOUR_ITEMS", 1);
}
showHideOnlyYourItems();
});
}
function showHideOnlyYourItems() {
$("#checkedlist tr:not(:first-child)").each(function() {
if(localStorage.getItem("ONLY_YOUR_ITEMS") == 1) {
if($(this).find("td:first").find("input").length < 2 && $(this).attr("class") != "group") {
$(this).hide();
}
}else {
$(this).show();
}
});
}
function progressBarPercentages() {
let classNames = [{"class": ".progressBar", "child": null},
{"class": ".greenProgressBar", "child": null},
{"class": ".blueProgressBar", "child": null},
{"class": ".plusMinusBar", "child": ".negholder"}];
classNames.forEach(function(element) {
$(element.class).each(function() {
let percent = $(this).attr("title");
if(percent.includes(' ')){
percent = percent.split(' ').slice(-1)[0] ;
}
if(element.child == null) {
$(this).prepend('
`); $("#mr_make_phone_call").click(function () { var peopleToCall = {run: 1, call_type: $("#mr_phone_call_combo").val(), last_called: 0, contacts: [] }; $(".data tbody > tr").each(function() { var charId = $(this).children().eq(0).find("a").attr("href").split("/").slice(-1)[0]; var isCharInSameCity = $(this).children().eq(0).find("a").html().includes(""); if(!isCharInSameCity) { if(!blocked_char_list.includes(charId)){ peopleToCall.contacts.push(charId); } } }); localStorage.setItem("MR_PHONE_CALL", JSON.stringify(peopleToCall)); }); } function controlPhoneCall() { var peopleToCall = localStorage.getItem("MR_PHONE_CALL"); if(peopleToCall && peopleToCall != "null") { peopleToCall = JSON.parse(peopleToCall); if(peopleToCall.run == 1) { var targetCharId = peopleToCall.contacts[peopleToCall.last_called]; if(!url.includes("/World/Popmundo.aspx/Interact/Phone/"+targetCharId)){ window.location.href = window.location.origin + "/World/Popmundo.aspx/Interact/Phone/"+targetCharId; }else{ if(peopleToCall.last_called == peopleToCall.contacts.length - 1) { peopleToCall.run = 0; }else{ peopleToCall.last_called = peopleToCall.last_called + 1; } if($("#ctl00_cphTopColumn_ctl00_btnInteract").length > 0) { mobilePhoneCallAutoChosenCombo(peopleToCall.call_type); $("#ctl00_cphTopColumn_ctl00_btnInteract").click(); }else{ targetCharId = peopleToCall.contacts[peopleToCall.last_called]; window.location.href = window.location.origin + "/World/Popmundo.aspx/Interact/Phone/"+targetCharId; } } } localStorage.setItem("MR_PHONE_CALL", JSON.stringify(peopleToCall)); } } })();