copyTerminal

Copie rapidement le contenu d'une page du TP (STV, Cryo, Historiques des entreprises et OI)

  1. // ==UserScript==
  2. // @name copyTerminal
  3. // @namespace InGame
  4. // @author RedLine
  5. // @date 01/02/2024
  6. // @version 1.1
  7. // @license DBAD - https://raw.githubusercontent.com/philsturgeon/dbad/master/translations/LICENSE-fr.md
  8. // @include https://www.dreadcast.net/Main
  9. // @compat Firefox, Chrome
  10. // @grant GM_setClipboard
  11. // @grant GM_addStyle
  12. // @require https://updategreasyfork.deno.dev/scripts/486572/1322825/jqueryUI%20-%20datepicker%20%20keycode%20only.js
  13. // @description Copie rapidement le contenu d'une page du TP (STV, Cryo, Historiques des entreprises et OI)
  14. // ==/UserScript==
  15. // 1.1 Correctif de l'impossibilité de s'équiper si on s'est pas déséquipés avant : Conflit dû à JqueryUI dans sa version complète.
  16.  
  17. GM_addStyle(`
  18. #downloadCurrentHistoryContainer {
  19. display: flex;
  20. }
  21. #downloadCurrentHistory {
  22. margin: auto;
  23. margin-top: 10px;
  24. margin-bottom: 15px;
  25. width: 25%;
  26. text-transform: uppercase;
  27. }
  28. #historyCalendarForm {
  29. width: 100%;
  30. }
  31. #historyCalendarInput {
  32. margin: auto;
  33. }
  34. #calendarButton {
  35. margin: auto;
  36. }
  37. #companyId {
  38. display:none
  39. }
  40. .ui-widget-header {
  41. background: linear-gradient(to bottom,#00839d 0,#002c3e 100%)
  42. }
  43. .ui-widget-content {
  44. border: 1px solid #ddd;
  45. background: #002c3e;
  46. color: #d2c556;
  47. box-shadow: inset 0 0 25px 10px #006974;
  48. }
  49. .ui-state-default, .ui-widget-content .ui-state-default {
  50. border: 0px solid #ccc;
  51. background: #030607 50% 50% repeat-x;
  52. background-color: rgb(2, 11, 15);
  53. background-position-x: 50%;
  54. background-position-y: 50%;
  55. background-repeat: repeat-x;
  56. background-attachment: scroll;
  57. background-image: none;
  58. background-size: auto;
  59. background-origin: padding-box;
  60. background-clip: border-box;
  61. font-weight: 700;
  62. color: #1c94c4;
  63. box-shadow: inset 0 0 5px 1px #006974;
  64. }
  65. .ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {
  66. border: 1px solid #fed22f;
  67. background: #ffe45c 50% top repeat-x;
  68. color: #363636;
  69. }
  70. .ui-datepicker select.ui-datepicker-month, .ui-datepicker select.ui-datepicker-year {
  71. width: 45%;
  72. color: #d2c556;
  73. }
  74. `);
  75.  
  76.  
  77. var datePicker = new Date();
  78. var monthPicker = datePicker.getMonth() + 1;
  79. var dayPicker = datePicker.getDate();
  80.  
  81. var datePickerOutput = (('' + dayPicker).length < 2 ? '0' : '') + dayPicker + '/' +
  82. (('' + monthPicker).length < 2 ? '0' : '') + monthPicker + '/' +
  83. datePicker.getFullYear();
  84.  
  85.  
  86. $(document).ready(function () {
  87. $(document).ajaxSuccess(function (e, xhr, opt) {
  88. if (opt.url.includes("/CrystalHistory")) {
  89.  
  90. if ($("#datepicker").length == 0) {
  91. $("#db_historique_cristaux").append('<form id="historyCalendarForm" class="longTextInput"/>');
  92. $("#historyCalendarForm").append('<div id="historyCalendarInput" class="mediumTextInput"></div>');
  93. $("#historyCalendarInput").append('<div class="left"></div>');
  94. $("#historyCalendarInput").append('<div class="right"></div>');
  95. $("#historyCalendarInput").append('<input type="text" id="datepicker" class="variableTextInput" />');
  96. $("#datepicker").val(datePickerOutput)
  97. function generateCalendar() {
  98. $("#datepicker").datepicker({ changeMonth: true, changeYear: true, minDate: new Date(2010, 10, 22) }); $.datepicker.setDefaults($.datepicker.regional["fr"]);
  99. }
  100.  
  101.  
  102. function generateDateTimestamp() {
  103.  
  104. var selectedDate = $("#datepicker").val();
  105. var formatDateToShittyUSFormat = selectedDate.split("/");
  106. var formattedDateInShittyUSFormat = formatDateToShittyUSFormat[1] + "/" + formatDateToShittyUSFormat[0] + "/" + formatDateToShittyUSFormat[2];
  107. generatedTimestamp = (new Date(formattedDateInShittyUSFormat).getTime()) / 1000;
  108. return generatedTimestamp
  109. }
  110.  
  111.  
  112. function generateHistoryURL() {
  113. var generatedDate = generateDateTimestamp()
  114. var historyURL = 'Main/DataBox/default=CrystalHistory&date=' + generatedDate
  115. return historyURL;
  116. }
  117. generateCalendar();
  118.  
  119. var $calendarButton = $("#historyCalendarInput").append('<div class="mediumValidInput" id="calendarButton"></div>');
  120. $calendarButton.click(function () { engine.regenerateDataBox(generateHistoryURL()) });
  121.  
  122. }
  123.  
  124.  
  125. var $button = $("#db_historique_cristaux").append('<div id="downloadCurrentHistoryContainer">');
  126. $("#downloadCurrentHistoryContainer").append('<button id="downloadCurrentHistory" class="btnTxt">Copier</button>');
  127. $button.click(function () {
  128. var copyText = $("#entreprise_historique").children().first().text().replace(/(\r\n|\n|\r|\t|")/gm, "").replace(/\s+/g, " ").replace(/Cr\. /gm, "Cr.\n").replace(/CF\ !\ /gm, "CF\!\n");
  129. GM_setClipboard(copyText);
  130. });
  131.  
  132.  
  133. }
  134.  
  135. if (opt.url.includes("/ListeCryoFull")) {
  136. var $button = $("#db_liste_cryo").append('<button id="downloadCurrentHistory" class="btnTxt">Copier</button>');
  137. $button.click(function () {
  138. var copyText = $("#imperial_data").text().replace(/(\r\n|\n|\r|\t|")/gm, "").replace(/\s+/g, " ").replace(/\[/g, "\r\n[");
  139. GM_setClipboard(copyText);
  140. });
  141. }
  142.  
  143. if (opt.url.includes("/DataBox/default=CompanyHistory")) {
  144.  
  145. if ($("#datepicker").length == 0) {
  146. $("#db_historique_entreprise").append('<form id="historyCalendarForm" class="longTextInput"/>');
  147. $("#historyCalendarForm").append('<div id="historyCalendarInput" class="mediumTextInput"></div>');
  148. $("#historyCalendarInput").append('<div class="left"></div>');
  149. $("#historyCalendarInput").append('<div class="right"></div>');
  150. $("#historyCalendarInput").append('<input type="text" id="datepicker" class="variableTextInput" />');
  151. $("#datepicker").val(datePickerOutput)
  152. function generateCalendar() {
  153. $("#datepicker").datepicker({ changeMonth: true, changeYear: true, minDate: new Date(2010, 10, 22) }); $.datepicker.setDefaults($.datepicker.regional["fr"]);
  154. }
  155.  
  156.  
  157. function generateDateTimestamp() {
  158.  
  159. var selectedDate = $("#datepicker").val();
  160. var formatDateToShittyUSFormat = selectedDate.split("/");
  161. var formattedDateInShittyUSFormat = formatDateToShittyUSFormat[1] + "/" + formatDateToShittyUSFormat[0] + "/" + formatDateToShittyUSFormat[2];
  162. generatedTimestamp = (new Date(formattedDateInShittyUSFormat).getTime()) / 1000;
  163. return generatedTimestamp
  164. }
  165.  
  166.  
  167. function generateHistoryURL() {
  168. var companyId = (opt.url).split("&")[1].split("=")[1];
  169. if ($("#companyId").length == 0) {
  170. $("#db_historique_entreprise").append('<div id=companyId>' + companyId + '</div>');
  171. }
  172. else {
  173. $("#companyId").text(companyId)
  174. }
  175. var generatedDate = generateDateTimestamp()
  176. var historyURL = 'Main/DataBox/default=CompanyHistory&company=' + companyId + '&date=' + generatedDate
  177. return historyURL;
  178. }
  179. generateCalendar();
  180.  
  181. var $calendarButton = $("#historyCalendarInput").append('<div class="mediumValidInput" id="calendarButton"></div>');
  182. $calendarButton.click(function () { engine.regenerateDataBox(generateHistoryURL()) });
  183.  
  184. }
  185.  
  186. if ($("#downloadCurrentHistory").length == 0) {
  187. $("#db_historique_entreprise").append('<div id="downloadCurrentHistoryContainer">');
  188. var $button = $("#downloadCurrentHistoryContainer").append('<button id="downloadCurrentHistory" class="btnTxt">Copier</button>');
  189.  
  190. $button.click(function () {
  191. var copyText = $("#entreprise_historique").children().eq(1).text().replace(/(\r|\t|")/gm, "").replace(/\s+/g, " ").replace(/Cr/gm, "Cr.\n").replace(/\ \[/gm, "\n [").replace(/(^\n)/gm, "").replace(/^\ /gm, "").replace(/\ $/gm, "\n");
  192. GM_setClipboard(copyText);
  193. });
  194. }
  195.  
  196. }
  197.  
  198. if (opt.url.includes("/SeeImperialData")) {
  199. $("#downloadCurrentHistoryContainer").remove()
  200. $("#historyCalendarForm").remove()
  201. $("#companyId").remove()
  202. }
  203.  
  204. else {
  205. return 0
  206. }
  207.  
  208. });
  209. });