Greasy Fork

Greasy Fork is available in English.

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!

当前为 2022-05-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Ics Viewer - ProtonMail
// @namespace    http://greasyfork.icu/en/users/670188-hacker09?sort=daily_installs
// @version      2
// @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.protonmail.com/*
// @include      https://protonirockerxow.onion/*
// @icon         https://protonmail.com/images/favicon.ico
// @require      http://greasyfork.icu/scripts/21927-arrive-js/code/arrivejs.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
})();