Ics Viewer - ProtonMail

Quickly see the .ics calendar file event information directly on your browser without having to download it or add it to any calendars!

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         Ics Viewer - ProtonMail
// @namespace    https://greasyfork.org/en/users/670188-hacker09?sort=daily_installs
// @version      4
// @description  Quickly see the .ics calendar file event information directly on your browser without having to download it or add it to any calendars!
// @author       hacker09
// @include      https://mail.proton.me/*
// @include      https://protonirockerxow.onion/*
// @icon         https://protonmail.com/images/favicon.ico
// @require      https://update.greasyfork.org/scripts/519092/arrivejs%20%28Latest%29.js
// @run-at       document-end
// @grant        none
// ==/UserScript==

(function() {
  'use strict';
  document.arrive('div.file-preview-text', (async function() { //Create a new async arrive function
    if (document.querySelector("div.file-preview-text").innerText.match('BEGIN:VCALENDAR') !== null) //If the file preview is of an .ics file
    { //Starts the if condition
      var Emails = []; //Creates a new array
      var Attendees = []; //Creates a new array
      var Location = ''; //Creates a new blank variable
      var Organizer = document.querySelector("div.file-preview-text").innerText.match(/(?<=ORGANIZER;CN=)[^:]+/)[0]; //Saves the Organizer name
      var TimeZone = document.querySelector("div.file-preview-text").innerText.match(/DTEND;TZID=(.*):/)[1].trim(); //Saves the TimeZone
      var Dates = document.querySelector("div.file-preview-text").innerText.match(/DTEND;TZID=.*:([0-9]*)/)[1].match(/.{1,2}/g); //Saves the event dates
      var TimeEnd = document.querySelector("div.file-preview-text").innerText.match(/DTEND;TZID=.*T([0-9]*)/)[1].match(/.{1,2}/g); //Saves the event end time
      var TimeStart = document.querySelector("div.file-preview-text").innerText.match(/DTSTART;TZID=.*T([0-9]*)/)[1].match(/.{1,2}/g); //Saves the event start time

      if (document.querySelector("div.file-preview-text").innerText.match(/LOCATION;LANGUAGE=.*:(.*\))/) !== null) //If the Location exists
      { //Starts the if condition
        Location = '\n\nLocation: ' + document.querySelector("div.file-preview-text").innerText.match(/LOCATION;LANGUAGE=.*:(.*\))/)[1].replaceAll('\\', ''); //Saves the event location
      } //Finishes the if condition

      document.querySelector("div.file-preview-text").innerText.match(/(?<=RSVP=.*;CN=)[^:]+/g).forEach(el => Attendees.push(el.replaceAll(/\r|\n /g, ''))); //Add each attendee to an array
      document.querySelector("div.file-preview-text").innerText.match(/(?<=:mailto:)[^;\\@]+@[^;\\@\r\n]*/g).forEach(el => Emails.push(el.replaceAll(/\r|\n /g, ''))); //Add each attendee email to an array

      document.querySelector("div.file-preview-text").innerText = 'Organizer: ' + Organizer + ' (' + Emails[0] + ')\n\nStarts: (YYYY/MM/DD) ' + Dates[0] + Dates[1] + '/' + Dates[2] + '/' + Dates[3] + ' at ' + TimeStart[0] + ':' + TimeStart[1] + ':' + TimeStart[2] + ' (' + TimeZone + ')\n\nEnds: (YYYY/MM/DD) ' + Dates[0] + Dates[1] + '/' + Dates[2] + '/' + Dates[3] + ' at ' + +TimeEnd[0] + ':' + TimeEnd[1] + ':' + TimeEnd[2] + ' (' + TimeZone + ')' + Location; //Show Organizer, Times and Location informations

      Attendees.forEach(function(el, i) { //ForEach Attendee
        document.querySelector("div.file-preview-text").innerText += '\n\nAttendees: ' + el + ' (' + Emails[i + 1] + ')'; //Show the Attendees names and emails
      }); //Finishes the foreach loop

      if (document.querySelector("div.file-preview-text").innerText.match(/(?<=DESCRIPTION;LANGUAGE=[^:]*:)[^:]*(?=UID:)/) !== null) //If the Description exists
      { //Starts the if condition
        var Description = document.querySelector("div.file-preview-text").innerText.match(/(?<=DESCRIPTION;LANGUAGE=[^:]*:)[^:]*(?=UID:)/)[0].replaceAll(/[\\]{1,2}[rn]? ?|\r|\n ?/g, '').replaceAll(/  /g, ' '); //Saves the event Description
        document.querySelector("div.file-preview-text").innerText += '\n\nDescription: ' + Description; //Show the event description
      } //Finishes the if condition
    } //Finishes the if condition
  })); //Finishes the async function
})();