// ==UserScript==
// @name The West Perseus Toolkit
// @author Mr. Perseus
// @namespace tw-perseus
// @description Useful tools for The West.
// @include https://*.the-west.*/game.php*
// @include http://*.the-west.*/game.php*
// @include https://*.tw.innogames.*/game.php*
// @include http://*.tw.innogames.*/game.php*
// @version 1.1.1
// @grant none
// @downloadURL none
// ==/UserScript==
(function(fn) {
const script = document.createElement('script');
script.setAttribute('type', 'application/javascript');
script.textContent = `(${fn})();`;
document.body.appendChild(script);
document.body.removeChild(script);
})(() => {
$(document).ready(() => {
const TWPT = {
base64: {
menuImage:
"url('data:image/jpeg;base64,/9j/4AAQSkZJRgABAQAASABIAAD/4QCMRXhpZgAATU0AKgAAAAgABQESAAMAAAABAAEAAAEaAAUAAAABAAAASgEbAAUAAAABAAAAUgEoAAMAAAABAAIAAIdpAAQAAAABAAAAWgAAAAAAAABIAAAAAQAAAEgAAAABAAOgAQADAAAAAQABAACgAgAEAAAAAQAAABmgAwAEAAAAAQAAABkAAAAA/+0AOFBob3Rvc2hvcCAzLjAAOEJJTQQEAAAAAAAAOEJJTQQlAAAAAAAQ1B2M2Y8AsgTpgAmY7PhCfv/AABEIABkAGQMBIgACEQEDEQH/xAAfAAABBQEBAQEBAQAAAAAAAAAAAQIDBAUGBwgJCgv/xAC1EAACAQMDAgQDBQUEBAAAAX0BAgMABBEFEiExQQYTUWEHInEUMoGRoQgjQrHBFVLR8CQzYnKCCQoWFxgZGiUmJygpKjQ1Njc4OTpDREVGR0hJSlNUVVZXWFlaY2RlZmdoaWpzdHV2d3h5eoOEhYaHiImKkpOUlZaXmJmaoqOkpaanqKmqsrO0tba3uLm6wsPExcbHyMnK0tPU1dbX2Nna4eLj5OXm5+jp6vHy8/T19vf4+fr/xAAfAQADAQEBAQEBAQEBAAAAAAAAAQIDBAUGBwgJCgv/xAC1EQACAQIEBAMEBwUEBAABAncAAQIDEQQFITEGEkFRB2FxEyIygQgUQpGhscEJIzNS8BVictEKFiQ04SXxFxgZGiYnKCkqNTY3ODk6Q0RFRkdISUpTVFVWV1hZWmNkZWZnaGlqc3R1dnd4eXqCg4SFhoeIiYqSk5SVlpeYmZqio6Slpqeoqaqys7S1tre4ubrCw8TFxsfIycrS09TV1tfY2dri4+Tl5ufo6ery8/T19vf4+fr/2wBDAAUDBAQEAwUEBAQFBQUGBwwIBwcHBw8LCwkMEQ8SEhEPERETFhwXExQaFRERGCEYGh0dHx8fExciJCIeJBweHx7/2wBDAQUFBQcGBw4ICA4eFBEUHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh4eHh7/3QAEAAL/2gAMAwEAAhEDEQA/APHLTT9Z1bU7101HUApunA2t8qgHp0rqbXwHq0ttuOo6kGI67zXpX7PEA1bw5rGmGCF3S6llRmAGMOSQTjjI5r0iNLRtEvpBEgCNEA2QNoO7+eBXwmPzDFqs4wdld213sfQUIUlH3o3/AOCfJHjfw54i8PKsrajqSLhHG9iMgkeorpvt93/z9Tf9917h+0FdaMPAWvQ3yJNeyWkK2I8v5rVgvLFv4geDtFeBbx6frXuZZiJ1qT53do4qyXNeKsf/0PP/AIdePv8AhHW1TTGvmtop7lvMHK5AbPb612yfEjRfIZBfwFWxkZPOOmRXmV1/rR9Kb2r5fE5LSxE/aOTR7VLHSpR5eVMu/E74gx6zaPZ28jTGQqhbDEkZ6fhUGW/55tUEf+tH1FSV3YXDQwkOSBz1q0q0rs//2Q==')",
},
version: '1.1.1',
settingsKey: 'TWPT_preferences',
defaultPreferences: {
CinemaSkipButton: true,
ZoomMap: true,
DisablePremiumNotifications: true,
NineTimesFifteenButton: true,
HideDrawingMap: true,
ChatImprovements: true,
},
preferences: {},
currentZoom: 1,
};
TWPT.Updater = {
init() {
setTimeout(TWPT.Updater.load, 5000);
},
load() {
$.getScript(
'https://rawcdn.githack.com/mr-perseus/tw-js-library/master/script-updater.js',
() => {
if (scriptUpdater.TWPT > TWPT.version) {
const updateMessage = new west.gui.Dialog(
'Update: The West Perseus Toolkit',
`Update Available
v${scriptUpdater.TWPT}:
${scriptUpdater.TWPTNew}`,
west.gui.Dialog.SYS_WARNING,
)
.addButton('Update', () => {
updateMessage.hide();
window.location.href =
'https://greasyfork.org/scripts/370137-the-west-perseus-toolkit/code/The%20West%20Perseus%20Toolkit.user.js';
})
.addButton('cancel')
.show();
}
},
);
},
};
TWPT.Settings = {
init() {
const storage = JSON.parse(
localStorage.getItem(TWPT.settingsKey),
);
TWPT.preferences = storage || TWPT.defaultPreferences;
const div = $('
${name}
`, ); }; const setCheckBox = function(prefName, text) { const checkbox = new west.gui.Checkbox(text); checkbox.setId(`TWPT_${prefName}`); if (TWPT.preferences[prefName]) { checkbox.toggle(); } checkbox.setCallback(() => { TWPT.preferences[prefName] = checkbox.isSelected(); localStorage.setItem( TWPT.settingsKey, JSON.stringify(TWPT.preferences), ); TWPT.Settings.refreshMenu(); new UserMessage( 'Okay. Please refresh your page.', 'success', ).show(); }); scrollPane.appendContent(checkbox.getMainDiv()); }; setTitle('Enabled Features'); setCheckBox( 'CinemaSkipButton', 'Enable the Cinema Skip button (allows to skip cinema videos after 5 seconds).', ); setCheckBox( 'ZoomMap', 'Enable the Zoom feature (hover the minimap icon on the top right and scroll up / down to zoom out / in).', ); setCheckBox( 'DisablePremiumNotifications', 'Suppress energy refill and automation premium notifications.', ); setCheckBox( 'NineTimesFifteenButton', 'Add a button to job windows which allows you to start 9x 15 second jobs at once.', ); setCheckBox( 'HideDrawingMap', 'Hides "Drawing Map" flag which is buggy sometimes.', ); setCheckBox( 'ChatImprovements', 'Enable Chat improvements: show online / idle status in Saloon chat.', ); setTitle('Feedback'); scrollPane.appendContent( '