Torn Custom Plane Image

Sets a custom plane image on the Torn Travel page.

  1. // ==UserScript==
  2. // @name Torn Custom Plane Image
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.0
  5. // @description Sets a custom plane image on the Torn Travel page.
  6. // @author TR0LL [2561502]
  7. // @match https://www.torn.com/page.php?sid=travel
  8. // @match https://www.torn.com/preferences.php
  9. // @grant GM_setValue
  10. // @grant GM_getValue
  11. // @license Proprietary
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16.  
  17. const defaultImage = "https://i.pinimg.com/originals/98/5e/ad/985ead90bd841958d2bb4b09ca60d123.gif";
  18.  
  19. function replacePlaneImage() {
  20. const planeImage = document.querySelector('.planeImage___Kbn3b');
  21. if (!planeImage) return;
  22.  
  23. const customImage = GM_getValue('permanentPlaneImage') || defaultImage;
  24. planeImage.src = customImage;
  25.  
  26. // Center the image
  27. planeImage.style.position = 'absolute';
  28. planeImage.style.top = '50%';
  29. planeImage.style.left = '50%';
  30. planeImage.style.transform = 'translate(-50%, -50%)';
  31. planeImage.style.maxWidth = '778px';
  32. planeImage.style.maxHeight = '300px';
  33. planeImage.style.width = 'auto';
  34. planeImage.style.height = 'auto';
  35. }
  36.  
  37. function addImageButton() {
  38. if (!window.location.href.startsWith("https://www.torn.com/preferences.php")) return;
  39.  
  40. const imageButton = document.createElement('button');
  41. imageButton.textContent = 'Set Plane Image';
  42. imageButton.style.padding = '8px 12px';
  43. imageButton.style.margin = '5px';
  44. imageButton.style.cursor = 'pointer';
  45. imageButton.style.backgroundColor = '#3498db';
  46. imageButton.style.color = 'white';
  47. imageButton.style.border = 'none';
  48. imageButton.style.borderRadius = '3px';
  49. imageButton.style.fontSize = '14px';
  50.  
  51. // Position the button on the right side of the screen
  52. imageButton.style.position = 'fixed';
  53. imageButton.style.top = '50%';
  54. imageButton.style.right = '20px'; // Adjust this value to change the distance from the right
  55. imageButton.style.transform = 'translateY(-50%)';
  56. imageButton.style.zIndex = '9999'; // Ensure it's above other elements
  57.  
  58. imageButton.addEventListener('click', () => {
  59. const imageUrl = prompt("Please enter the image URL");
  60. if (imageUrl){
  61. GM_setValue('permanentPlaneImage', imageUrl);
  62. replacePlaneImage();
  63. }
  64. });
  65.  
  66. document.body.appendChild(imageButton);
  67. }
  68.  
  69. replacePlaneImage();
  70. addImageButton();
  71.  
  72. const observer = new MutationObserver(mutations => {
  73. replacePlaneImage();
  74. });
  75.  
  76. observer.observe(document.body, {
  77. childList: true,
  78. subtree: true
  79. });
  80. })();