Ακριβής-Προβολέας-Χρόνου-Για-Instagram

Μετατρέπει τα χρονικά στοιχεία του Instagram στην τοπική ζώνη ώρας στη μορφή της τοπικής ζώνης ώρας του χρήστη με προσθήκη πληροφοριών ζώνης ώρας.

  1. // ==UserScript==
  2. // @name Exact-Time-Viewer-For-Instagram
  3. // @description Converts Instagram time elements to local time zone in user's local time zone format with time zone info added.
  4. // @name:ar عارض-الوقت-الدقيق-لإنستغرام
  5. // @description:ar يحول عناصر وقت إنستغرام إلى المنطقة الزمنية المحلية بتنسيق المنطقة الزمنية المحلية للمستخدم مع إضافة معلومات المنطقة الزمنية.
  6. // @name:bg Точен-Преглед-на-Време-за-Инстаграм
  7. // @description:bg Преобразува елементите за време в Инстаграм в местната часова зона във формата на местната часова зона на потребителя с добавена информация за часовата зона.
  8. // @name:cs Přesný-Zobrazovač-Času-Pro-Instagram
  9. // @description:cs Převádí časové prvky Instagramu do místního časového pásma ve formátu místního časového pásma uživatele s přidanými informacemi o časovém pásmu.
  10. // @name:da Nøjagtig-Tidsviser-Til-Instagram
  11. // @description:da Konverterer Instagram-tidselementer til lokal tidszone i brugerens lokale tidszoneformat med tilføjede tidszoneoplysninger.
  12. // @name:de Genaue-Zeit-Anzeige-Für-Instagram
  13. // @description:de Wandelt Instagram-Zeitelemente in die lokale Zeitzone im Format der lokalen Zeitzone des Benutzers um und fügt Zeitzoneninformationen hinzu.
  14. // @name:el Ακριβής-Προβολέας-Χρόνου-Για-Instagram
  15. // @description:el Μετατρέπει τα χρονικά στοιχεία του Instagram στην τοπική ζώνη ώρας στη μορφή της τοπικής ζώνης ώρας του χρήστη με προσθήκη πληροφοριών ζώνης ώρας.
  16. // @name:en Exact-Time-Viewer-For-Instagram
  17. // @description:en Converts Instagram time elements to local time zone in user's local time zone format with time zone info added.
  18. // @name:eo Ekzakta-Tempo-Vidilo-Por-Instagram
  19. // @description:eo Konvertas Instagram-tempajn elementojn al loka horzono en la loka horzona formato de la uzanto kun aldonitaj horzonaj informoj.
  20. // @name:es Visor-de-Tiempo-Exacto-Para-Instagram
  21. // @description:es Convierte los elementos de tiempo de Instagram a la zona horaria local en el formato de la zona horaria local del usuario con información de zona horaria añadida.
  22. // @name:fi Tarkka-Aikanäkymä-Instagramille
  23. // @description:fi Muuntaa Instagramin aikaelementit paikalliseen aikavyöhykkeeseen käyttäjän paikallisessa aikavyöhykeformaatissa lisättyjen aikavyöhyketietojen kera.
  24. // @name:fr Visionneur-de-Temps-Exact-Pour-Instagram
  25. // @description:fr Convertit les éléments de temps d'Instagram en fuseau horaire local dans le format du fuseau horaire local de l'utilisateur avec des informations de fuseau horaire ajoutées.
  26. // @name:fr-CA Visionneur-de-Temps-Précis-Pour-Instagram
  27. // @description:fr-CA Convertit les éléments temporels d'Instagram au fuseau horaire local dans le format du fuseau horaire local de l'utilisateur avec des infos de fuseau horaire ajoutées.
  28. // @name:he צופה-זמן-מדויק-לאינסטגרם
  29. // @description:he ממיר את רכיבי הזמן של אינסטגרם לאזור הזמן המקומי בפורמט אזור הזמן המקומי של המשתמש עם מידע נוסף על אזור הזמן.
  30. // @name:hr Točni-Prikazivač-Vremena-Za-Instagram
  31. // @description:hr Pretvara vremenske elemente Instagrama u lokalnu vremensku zonu u formatu lokalne vremenske zone korisnika s dodanim informacijama o vremenskoj zoni.
  32. // @name:hu Pontos-Idő-Néző-Az-Instagramhoz
  33. // @description:hu Az Instagram időelemeit a helyi időzónába konvertálja a felhasználó helyi időzóna formátumában, időzóna-információval kiegészítve.
  34. // @name:id Penampil-Waktu-Tepat-Untuk-Instagram
  35. // @description:id Mengonversi elemen waktu Instagram ke zona waktu lokal dalam format zona waktu lokal pengguna dengan informasi zona waktu ditambahkan.
  36. // @name:it Visualizzatore-di-Tempo-Esatto-Per-Instagram
  37. // @description:it Converte gli elementi temporali di Instagram nel fuso orario locale nel formato del fuso orario locale dell'utente con informazioni sul fuso orario aggiunte.
  38. // @name:ja インスタグラム用正確時間ビューア
  39. // @description:ja インスタグラムの時間要素をユーザーのローカルタイムゾーンフォーマットでローカルタイムゾーンに変換し、タイムゾーン情報を追加します。
  40. // @name:ka ზუსტი-დროის-მაჩვენებელი-ინსტაგრამისთვის
  41. // @description:ka გარდაქმნის ინსტაგრამის დროის ელემენტებს ადგილობრივ დროის სარტყელში მომხმარებლის ადგილობრივი დროის სარტყლის ფორმატში, დროის სარტყლის ინფორმაციის დამატებით.
  42. // @name:ko 인스타그램용-정확한-시간-뷰어
  43. // @description:ko 인스타그램 시간 요소를 사용자의 로컬 시간대 형식으로 로컬 시간대에 변환하고 시간대 정보를 추가합니다.
  44. // @name:nb Nøyaktig-Tidsviser-For-Instagram
  45. // @description:nb Konverterer Instagram-tidselementer til lokal tidssone i brukerens lokale tidssoneformat med tidssoneinformasjon lagt til.
  46. // @name:nl Exacte-Tijd-Weergever-Voor-Instagram
  47. // @description:nl Converteert Instagram-tijdelementen naar lokale tijdzone in het lokale tijdzoneformaat van de gebruiker met toegevoegde tijdzone-informatie.
  48. // @name:pl Dokładny-Wyświetlacz-Czasu-Dla-Instagrama
  49. // @description:pl Konwertuje elementy czasu Instagrama na lokalną strefę czasową w formacie lokalnej strefy czasowej użytkownika z dodanymi informacjami o strefie czasowej.
  50. // @name:pt-BR Visualizador-de-Tempo-Exato-Para-Instagram
  51. // @description:pt-BR Converte elementos de tempo do Instagram para o fuso horário local no formato do fuso horário local do usuário com informações de fuso horário adicionadas.
  52. // @name:ro Vizualizator-de-Timp-Exact-Pentru-Instagram
  53. // @description:ro Convertește elementele de timp ale Instagram în fusul orar local în formatul fusului orar local al utilizatorului, cu informații despre fusul orar adăugate.
  54. // @name:ru Точный-Просмотрщик-Времени-Для-Инстаграма
  55. // @description:ru Преобразует временные элементы Instagram в местный часовой пояс в формате местного часового пояса пользователя с добавленной информацией о часовом поясе.
  56. // @name:sk Presný-Zobrazovač-Času-Pre-Instagram
  57. // @description:sk Premieňa časové prvky Instagramu na miestnu časovú zónu vo formáte miestnej časovej zóny používateľa s pridanými informáciami o časovej zóne.
  58. // @name:sr Тачан-Прегледач-Времена-За-Инстаграм
  59. // @description:sr Претвара временске елементе Инстаграма у локалну временску зону у формату локалне временске зоне корисника са додатим информацијама о временској зони.
  60. // @name:sv Exakt-Tidsvisare-För-Instagram
  61. // @description:sv Konverterar Instagram-tidelement till lokal tidszon i användarens lokala tidszonsformat med tidszonsinformation tillagd.
  62. // @name:th ตัวแสดงเวลาแม่นยำสำหรับอินสตาแกรม
  63. // @description:th แปลงองค์ประกอบเวลาของอินสตาแกรมเป็นเขตเวลาท้องถิ่นในรูปแบบเขตเวลาท้องถิ่นของผู้ใช้พร้อมข้อมูลเขตเวลาเพิ่มเติม.
  64. // @name:tr Instagram-İçin-Kesin-Zaman-Görüntüleyici
  65. // @description:tr Instagram zaman öğelerini kullanıcının yerel saat dilimi formatında yerel saat dilimine dönüştürür ve saat dilimi bilgisi ekler.
  66. // @name:ug Instagram-ئۈچۈن-ئېنىق-ۋاقىت-كۆرگۈچى
  67. // @description:ug Instagram ۋاقىت ئېلېمېنتلىرىنى ئىشلەتكۈچىنىڭ يەرلىك ۋاقىت رايونى فورماتىدا يەرلىك ۋاقىت رايونىغا ئايلاندۇرىدۇ ۋە ۋاقىت رايونى ئۇچۇرى قوشىدۇ.
  68. // @name:uk Точний-Переглядач-Часу-Для-Інстаграма
  69. // @description:uk Перетворює часові елементи Instagram на місцевий часовий пояс у форматі місцевого часового поясу користувача з додаванням інформації про часовий пояс.
  70. // @name:vi Trình-Xem-Giờ-Chính-Xác-Cho-Instagram
  71. // @description:vi Chuyển đổi các yếu tố thời gian của Instagram sang múi giờ địa phương theo định dạng múi giờ địa phương của người dùng với thông tin múi giờ được thêm vào.
  72. // @name:zh Instagram精确时间查看器
  73. // @description:zh 将Instagram时间元素转换为用户本地时区格式的本地时区,并添加时区信息。
  74. // @name:zh-CN Instagram精确时间查看器
  75. // @description:zh-CN 将Instagram时间元素转换为用户本地时区格式的本地时区,并添加时区信息。
  76. // @name:zh-HK Instagram精確時間檢視器
  77. // @description:zh-HK 將Instagram時間元素轉換為用戶本地時區格式嘅本地時區,並添加時區資訊。
  78. // @name:zh-SG Instagram精确时间查看器
  79. // @description:zh-SG 将Instagram时间元素转换为用户本地时区格式的本地时区,并添加时区信息。
  80. // @name:zh-TW Instagram精確時間檢視器
  81. // @description:zh-TW 將Instagram時間元素轉換為使用者本地時區格式的本地時區,並新增時區資訊。
  82. // @namespace http://tampermonkey.net/
  83. // @version 1.1.3.4
  84. // @match *://*.instagram.com/*
  85. // @icon https://static.cdninstagram.com/rsrc.php/v4/yI/r/VsNE-OHk_8a.png
  86. // @author aspen138
  87. // @grant GM_registerMenuCommand
  88. // @grant GM_unregisterMenuCommand
  89. // @grant GM_setValue
  90. // @grant GM_getValue
  91. // @grant GM_notification
  92. // @grant GM_info
  93. // @grant window.onurlchange
  94. // @license MIT
  95. // ==/UserScript==
  96.  
  97. // Port the chrome extension `Exact-Time-Viewer-For-Instagram` to tampermonkey script
  98. // reference: https://github.com/ehmorris/Exact-Time-Viewer-For-Instagram
  99.  
  100.  
  101.  
  102.  
  103. // ↓↓↓↓↓↓↓↓↓模板,建议直接复制 //
  104.  
  105. // 自定义 urlchange 事件(用来监听 URL 变化)
  106. function addUrlChangeEvent() {
  107. history.pushState = (f => function pushState() {
  108. var ret = f.apply(this, arguments);
  109. window.dispatchEvent(new Event('pushstate'));
  110. window.dispatchEvent(new Event('urlchange'));
  111. return ret;
  112. })(history.pushState);
  113.  
  114. history.replaceState = (f => function replaceState() {
  115. var ret = f.apply(this, arguments);
  116. window.dispatchEvent(new Event('replacestate'));
  117. window.dispatchEvent(new Event('urlchange'));
  118. return ret;
  119. })(history.replaceState);
  120.  
  121. window.addEventListener('popstate', () => {
  122. window.dispatchEvent(new Event('urlchange'))
  123. });
  124. }
  125.  
  126.  
  127. var menu_ALL = [
  128. ['menu_isEnableDirectlyShowExactTime', 'Directly Show Exact Time', 'Directly Show Exact Time', true]
  129. ],
  130. menu_ID = [];
  131. for (let i = 0; i < menu_ALL.length; i++) { // 如果读取到的值为 null 就写入默认值
  132. if (GM_getValue(menu_ALL[i][0]) == null) {
  133. GM_setValue(menu_ALL[i][0], menu_ALL[i][3])
  134. };
  135. }
  136.  
  137.  
  138. // 注册脚本菜单
  139. function registerMenuCommand() {
  140. if (menu_ID.length >= menu_ALL.length) { // 如果菜单ID数组长度大于等于菜单数组长度,说明不是首次添加菜单,需要卸载所有脚本菜单
  141. for (let i = 0; i < menu_ID.length; i++) {
  142. GM_unregisterMenuCommand(menu_ID[i]);
  143. }
  144. }
  145. for (let i = 0; i < menu_ALL.length; i++) { // 循环注册脚本菜单
  146. menu_ALL[i][3] = GM_getValue(menu_ALL[i][0]);
  147. menu_ID[i] = GM_registerMenuCommand(`${menu_ALL[i][3]?'✅':'❌'} ${menu_ALL[i][1]}`, function() {
  148. menu_switch(`${menu_ALL[i][3]}`, `${menu_ALL[i][0]}`, `${menu_ALL[i][2]}`)
  149. });
  150. }
  151. }
  152.  
  153.  
  154. // 菜单开关
  155. function menu_switch(menu_status, Name, Tips) {
  156. if (menu_status == 'true') {
  157. GM_setValue(`${Name}`, false);
  158. GM_notification({
  159. text: `已关闭 [${Tips}] 功能\n(点击刷新网页后生效)`,
  160. timeout: 3500,
  161. onclick: function() {
  162. location.reload();
  163. }
  164. });
  165. } else {
  166. GM_setValue(`${Name}`, true);
  167. GM_notification({
  168. text: `已开启 [${Tips}] 功能\n(点击刷新网页后生效)`,
  169. timeout: 3500,
  170. onclick: function() {
  171. location.reload();
  172. }
  173. });
  174. }
  175. registerMenuCommand(); // 重新注册脚本菜单
  176. };
  177.  
  178.  
  179. // 返回菜单值
  180. function menu_value(menuName) {
  181. for (let menu of menu_ALL) {
  182. if (menu[0] == menuName) {
  183. return menu[3]
  184. }
  185. }
  186. }
  187.  
  188. for (let i = 0; i < menu_ALL.length; i++) { // 如果读取到的值为 null 就写入默认值
  189. if (GM_getValue(menu_ALL[i][0]) == null) {
  190. GM_setValue(menu_ALL[i][0], menu_ALL[i][3])
  191. };
  192. }
  193. registerMenuCommand();
  194. if (window.onurlchange === undefined) {
  195. addUrlChangeEvent();
  196. } // Tampermonkey v4.11 版本添加的 onurlchange 事件 grant,可以监控 pjax 等网页的 URL 变化
  197.  
  198. // ↑↑↑↑↑↑↑↑↑↑↑↑模板,建议直接复制 //
  199.  
  200.  
  201.  
  202.  
  203. if (GM_getValue('menu_isEnableDirectlyShowExactTime', true)) {
  204. (function() {
  205. 'use strict';
  206.  
  207. const processedElements = new WeakSet();
  208.  
  209. function formatDate(datetime) {
  210. const dateObject = new Date(datetime);
  211. const time = dateObject.toLocaleTimeString();
  212. const dayOfWeek = dateObject.toLocaleDateString(undefined, { weekday: 'long' });
  213. const date = dateObject.toLocaleDateString();
  214. const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  215. return `${time}, ${dayOfWeek} ${date} (in the ${localTimeZone} time zone)`;
  216. // return `${time}, ${dayOfWeek} ${date}`;
  217. }
  218.  
  219. function processTimeElement(element) {
  220. if (!processedElements.has(element)) {
  221. const datetime = element.getAttribute('datetime');
  222. if (datetime) {
  223. const formattedDate = formatDate(datetime);
  224.  
  225. // Store the original content as a data attribute
  226. const originalContent = element.innerHTML;
  227. element.setAttribute('data-original-content', originalContent);
  228.  
  229. // Directly replace the content with the formatted date
  230. element.innerHTML = formattedDate;
  231.  
  232. processedElements.add(element);
  233. }
  234. }
  235. }
  236.  
  237. function processTimeElements(root) {
  238. const timeElements = root.querySelectorAll('time[datetime]');
  239. timeElements.forEach(element => {
  240. processTimeElement(element);
  241. });
  242. }
  243.  
  244. // Process existing <time> elements on the page
  245. processTimeElements(document);
  246.  
  247. // Observe for future <time> elements added to the DOM
  248. const observer = new MutationObserver(mutations => {
  249. mutations.forEach(mutation => {
  250. mutation.addedNodes.forEach(node => {
  251. if (node.nodeType === 1) { // Node.ELEMENT_NODE
  252. if (node.tagName && node.tagName.toUpperCase() === 'TIME') {
  253. processTimeElement(node);
  254. } else {
  255. processTimeElements(node);
  256. }
  257. }
  258. });
  259. });
  260. });
  261.  
  262. observer.observe(document.body, {
  263. childList: true,
  264. subtree: true
  265. });
  266.  
  267. })();
  268. } else {
  269. (function() {
  270. 'use strict';
  271.  
  272. const processedElements = new WeakSet();
  273.  
  274. function formatDate(datetime) {
  275. const dateObject = new Date(datetime);
  276. const time = dateObject.toLocaleTimeString();
  277. const dayOfWeek = dateObject.toLocaleDateString(undefined, { weekday: 'long' });
  278. const date = dateObject.toLocaleDateString();
  279. const localTimeZone = Intl.DateTimeFormat().resolvedOptions().timeZone;
  280. return `${time}, ${dayOfWeek} ${date} (in the ${localTimeZone} time zone)`;
  281. // return `${time}, ${dayOfWeek} ${date}`;
  282. }
  283.  
  284. function processTimeElement(element) {
  285. if (!processedElements.has(element)) {
  286. const datetime = element.getAttribute('datetime');
  287. if (datetime) {
  288. const formattedDate = formatDate(datetime);
  289. const originalContent = element.innerHTML;
  290.  
  291. // Store the original content as a data attribute
  292. element.setAttribute('data-original-content', originalContent);
  293.  
  294. // Add event listeners for hover and leave
  295. element.addEventListener('mouseover', () => {
  296. element.innerHTML = formattedDate;
  297. });
  298.  
  299. element.addEventListener('mouseleave', () => {
  300. element.innerHTML = originalContent;
  301. });
  302.  
  303. processedElements.add(element);
  304. }
  305. }
  306. }
  307.  
  308. function processTimeElements(root) {
  309. const timeElements = root.querySelectorAll('time[datetime]');
  310. timeElements.forEach(element => {
  311. processTimeElement(element);
  312. });
  313. }
  314.  
  315. // Process existing <time> elements on the page
  316. processTimeElements(document);
  317.  
  318. // Observe for future <time> elements added to the DOM
  319. const observer = new MutationObserver(mutations => {
  320. mutations.forEach(mutation => {
  321. mutation.addedNodes.forEach(node => {
  322. if (node.nodeType === 1) { // Node.ELEMENT_NODE
  323. if (node.tagName && node.tagName.toUpperCase() === 'TIME') {
  324. processTimeElement(node);
  325. } else {
  326. processTimeElements(node);
  327. }
  328. }
  329. });
  330. });
  331. });
  332.  
  333. observer.observe(document.body, {
  334. childList: true,
  335. subtree: true
  336. });
  337.  
  338. })();
  339. }