Vie Steam-kauppahistoria

Vie Steam-kauppahistoria TSV-tiedostoon

Asenna tämä skripti?
Author's suggested script

Saatat myös pitää

Asenna tämä skripti
  1. // ==UserScript==
  2. // @name Export Steam TradeHistory
  3. // @name:bg Експортиране на историята на търговията в Steam
  4. // @name:cs Exportovat historii obchodů na Steamu
  5. // @name:da Eksporter Steam-handelshistorik
  6. // @name:de Steam-Handelsverlauf exportieren
  7. // @name:el Εξαγωγή ιστορικού συναλλαγών Steam
  8. // @name:en Export Steam TradeHistory
  9. // @name:eo Eksporti Steam-komercan historion
  10. // @name:es Exportar Historial de Intercambios de Steam
  11. // @name:es-la Exportar Historial de Intercambios de Steam
  12. // @name:es-419 Exportar Historial de Intercambios de Steam
  13. // @name:fi Vie Steam-kauppahistoria
  14. // @name:fr Exporter l'historique des échanges Steam
  15. // @name:fr-CA Exporter l'historique des échanges Steam
  16. // @name:he ייצוא היסטוריית המסחר של Steam
  17. // @name:hr Izvoz povijesti trgovanja na Steamu
  18. // @name:hu Steam kereskedelmi előzmények exportálása
  19. // @name:id Ekspor Riwayat Perdagangan Steam
  20. // @name:it Esporta Cronologia Scambi di Steam
  21. // @name:ja Steam取引履歴のエクスポート
  22. // @name:ka ექსპორტი Steam-ის სავაჭრო ისტორია
  23. // @name:ko Steam 거래 내역 내보내기
  24. // @name:nb Eksporter Steam-handelshistorikk
  25. // @name:nl Exporteer Steam-handelsgeschiedenis
  26. // @name:pl Eksportuj historię handlu Steam
  27. // @name:pt-BR Exportar Histórico de Trocas do Steam
  28. // @name:ro Exportă istoricul tranzacțiilor Steam
  29. // @name:sv Exportera Steam-handels historik
  30. // @name:th ส่งออกประวัติการซื้อขาย Steam
  31. // @name:tr Steam Ticaret Geçmişini Dışa Aktar
  32. // @name:ug Steam سودا تارىخىنى ئېكسپورت قىلىش
  33. // @name:uk Експортувати історію торгів Steam
  34. // @name:vi Xuất lịch sử giao dịch Steam
  35. // @name:zh-TW 匯出 Steam 交易歷史
  36. // @namespace https://jlcareglio.github.io/
  37. // @version 1.2.2
  38. // @description Export Steam trade history to a TSV file
  39. // @description:bg Експортиране на историята на търговията в Steam в TSV файл
  40. // @description:cs Exportovat historii obchodů na Steamu do TSV souboru
  41. // @description:da Eksporter Steam-handelshistorik til en TSV-fil
  42. // @description:de Exportieren Sie den Steam-Handelsverlauf in eine TSV-Datei
  43. // @description:el Εξαγωγή ιστορικού συναλλαγών Steam σε αρχείο TSV
  44. // @description:en Export Steam trade history to a TSV file
  45. // @description:eo Eksporti Steam-komercan historion al TSV-dosiero
  46. // @description:es Permite exportar el historial de intercambios de Steam a un archivo TSV
  47. // @description:es-la Permite exportar el historial de intercambios de Steam a un archivo TSV
  48. // @description:es-419 Permite exportar el historial de intercambios de Steam a un archivo TSV
  49. // @description:fi Vie Steam-kauppahistoria TSV-tiedostoon
  50. // @description:fr Exporter l'historique des échanges Steam dans un fichier TSV
  51. // @description:fr-CA Exporter l'historique des échanges Steam dans un fichier TSV
  52. // @description:he ייצוא היסטוריית המסחר של Steam לקובץ TSV
  53. // @description:hr Izvoz povijesti trgovanja na Steamu u TSV datoteku
  54. // @description:hu Steam kereskedelmi előzmények exportálása TSV fájlba
  55. // @description:id Ekspor Riwayat Perdagangan Steam ke file TSV
  56. // @description:it Esporta la cronologia degli scambi di Steam in un file TSV
  57. // @description:ja Steam取引履歴をTSVファイルにエクスポート
  58. // @description:ka ექსპორტი Steam-ის სავაჭრო ისტორია TSV ფაილში
  59. // @description:ko Steam 거래 내역을 TSV 파일로 내보내기
  60. // @description:nb Eksporter Steam-handelshistorikk til en TSV-fil
  61. // @description:nl Exporteer Steam-handelsgeschiedenis naar een TSV-bestand
  62. // @description:pl Eksportuj historię handlu Steam do pliku TSV
  63. // @description:pt-BR Exportar o histórico de trocas do Steam para um arquivo TSV
  64. // @description:ro Exportă istoricul tranzacțiilor Steam într-un fișier TSV
  65. // @description:sv Exportera Steam-handels historik till en TSV-fil
  66. // @description:th ส่งออกประวัติการซื้อขาย Steam เป็นไฟล์ TSV
  67. // @description:tr Steam ticaret geçmişini TSV dosyasına aktar
  68. // @description:ug Steam سودا تارىخىنى TSV ھۆججىتىگە ئېكسپورت قىلىش
  69. // @description:uk Експортувати історію торгів Steam у файл TSV
  70. // @description:vi Xuất lịch sử giao dịch Steam sang tệp TSV
  71. // @description:zh-TW 匯出 Steam 交易歷史到 TSV 檔案
  72. // @icon https://www.google.com/s2/favicons?sz=64&domain=steamcommunity.com
  73. // @grant none
  74. // @author Jesús Lautaro Careglio Albornoz
  75. // @source https://gist.githubusercontent.com/JLCareglio/00bef3fb30b3dedd9f0dd849c9bd461a/raw/01_Export-Steam-TradeHistory.user.js
  76. // @match *://steamcommunity.com/profiles/*/tradehistory*
  77. // @match *://steamcommunity.com/id/*/tradehistory*
  78. // @license MIT
  79. // @compatible firefox
  80. // @compatible chrome
  81. // @compatible opera
  82. // @compatible safari
  83. // @compatible edge
  84. // @compatible brave
  85. // @supportURL https://gist.github.com/JLCareglio/00bef3fb30b3dedd9f0dd849c9bd461a/
  86. // ==/UserScript==
  87.  
  88. (async () => {
  89. const pagInGrowBar = document.querySelector(".inventory_history_pagingrow");
  90. const btnNext = pagInGrowBar.querySelector(".inventory_history_nextbtn");
  91. const tradeHistoryRows = document.querySelectorAll(".tradehistoryrow");
  92. const btnExport = document.createElement("div");
  93.  
  94. const exportTradeHistory = () => {
  95. const trades = Array.from(tradeHistoryRows).map((row) => {
  96. // Convertir fecha y hora al formato deseado
  97. const dateText = row
  98. .querySelector(".tradehistory_date")
  99. .childNodes[0].textContent.trim();
  100. const timeText = row
  101. .querySelector(".tradehistory_timestamp")
  102. .textContent.trim();
  103.  
  104. const monthMap = {
  105. ENE: "01",
  106. FEB: "02",
  107. MAR: "03",
  108. ABR: "04",
  109. MAY: "05",
  110. JUN: "06",
  111. JUL: "07",
  112. AGO: "08",
  113. SEP: "09",
  114. OCT: "10",
  115. NOV: "11",
  116. DIC: "12",
  117. };
  118.  
  119. const [day, month, year] = dateText.split(" ");
  120. const monthNum = monthMap[month];
  121. const time = timeText.replace(" a. m.", "").replace(" p. m.", "");
  122.  
  123. const datetime = `${day.padStart(2, "0")}/${monthNum}/${year} ${time}`;
  124.  
  125. const userLink = row.querySelector(".tradehistory_event_description a");
  126. const userId = userLink.href.split("/").pop();
  127. const username = userLink.textContent;
  128. const items = Array.from(row.querySelectorAll(".history_item_name")).map(
  129. (item) => item.textContent.trim()
  130. );
  131.  
  132. return {
  133. datetime,
  134. user: {
  135. id: userId,
  136. name: username,
  137. },
  138. items,
  139. };
  140. });
  141.  
  142. const tsvHeader = "Date&Time\tUserID\tUserName\tItems";
  143. const tsvContent = trades
  144. .map((trade) => {
  145. const items = trade.items.join(", ");
  146. return `${trade.datetime}\t${trade.user.id}\t${trade.user.name}\t${items}`;
  147. })
  148. .join("\n");
  149.  
  150. const tsvData = `${tsvHeader}\n${tsvContent}`;
  151.  
  152. const blob = new Blob([tsvData], { type: "text/tab-separated-values" });
  153. const url = URL.createObjectURL(blob);
  154. const a = document.createElement("a");
  155. a.href = url;
  156. a.download = "steam_trade_history.tsv";
  157. document.body.appendChild(a);
  158. a.click();
  159. document.body.removeChild(a);
  160. URL.revokeObjectURL(url);
  161. };
  162.  
  163. const customStyle = document.createElement("style");
  164. customStyle.textContent = `
  165. .btnExport {
  166. position: relative;
  167. }
  168. .btnExport:before {
  169. pointer-events: none;
  170. content: "";
  171. position: absolute;
  172. left: 6px;
  173. top: 0;
  174. bottom: 0;
  175. width: 20px;
  176. background: url("data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg' fill='%2366c0f4' fill-rule='evenodd' clip-rule='evenodd'%3E%3Cpath d='M16 2v7h-2v-5h-12v16h12v-5h2v7h-16v-20h16zm2 9v-4l6 5-6 5v-4h-10v-2h10z'/%3E%3C/svg%3E") center / contain no-repeat;
  177. transition: background-image 0.2s ease;
  178. }
  179. .btnExport:hover:before {
  180. background: url("data:image/svg+xml,%3Csvg width='24' height='24' xmlns='http://www.w3.org/2000/svg' fill='%23fff' fill-rule='evenodd' clip-rule='evenodd'%3E%3Cpath d='M16 2v7h-2v-5h-12v16h12v-5h2v7h-16v-20h16zm2 9v-4l6 5-6 5v-4h-10v-2h10z'/%3E%3C/svg%3E") center / contain no-repeat;
  181. }
  182.  
  183. .btnExport .pagebtn {
  184. padding-left: 28px !important;
  185. padding-right: 6px !important;
  186. transition: color 0.2s ease, background-color 0.2s ease;
  187. }
  188. `;
  189.  
  190. document.head.appendChild(customStyle);
  191.  
  192. btnExport.classList.add("inventory_history_nextbtn", "btnExport");
  193. btnExport.innerHTML = `<a class="pagebtn">TSV</a>`;
  194. btnExport.addEventListener("click", exportTradeHistory);
  195. pagInGrowBar.insertBefore(btnExport, btnNext.nextSibling);
  196. })();