Spike quoted mail fix

Removes quoted text from Spike messages in unsupported languages and default junk signatures (style "Sent from my iThingy").

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Spike quoted mail fix
// @namespace    http://tampermonkey.net/
// @version      2024-02-11
// @description  Removes quoted text from Spike messages in unsupported languages and default junk signatures (style "Sent from my iThingy").
// @author       PiPauwels
// @match        https://spikenow.com/web/*
// @require      https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js
// @require      https://update.greasyfork.org/scripts/383527/701631/Wait_for_key_elements.js
// @icon         https://www.google.com/s2/favicons?sz=64&domain=spikenow.com
// @grant        GM.getValue
// ==/UserScript==

const QUOTED_TEXT_REGEX_DUT = /\n?\s?Op\s(maandag|dinsdag|woensdag|donderdag|vrijdag|zaterdag|zondag|ma|di|wo|do|vr|za|zo)?\s?\d+\s.*(schreef|heeft).*(<|lt;)+.*@.*(>|gt;)+.*(geschreven)?(.*|\n)*/g;
const DEFAULT_SIG_1 = /Enviado (de mi|de|desde) ((<|&lt;)a.*(>|&gt;)+)?.*(.*|\n)*/g;
const DEFAULT_SIG_2 = /Verstuurd vanaf mijn iPhone(.*|\n)*/g;
const ORIGINAL_MSG = /-------- Oorspronkelijk bericht --------(.*|\n)*/g;
const TRAILING_NEWLINES = /(<br>|<br\/>|\s)+$/g;
const TRAILING_EMPTY_DIVS = /(<div dir="auto"><br><\/div>|\n)*(<div><br><\/div>|<div id="ms-outlook-mobile-signature" dir="auto"><\/div>)/g;

waitForKeyElements (".thread", addThreadListener, false);

function addThreadListener (jNode) { jNode.click(function(){ clickThread(); }); }

function clickThread()
{
    waitForKeyElements ("#__hop_embed", stripQuotedText, true, ".messageframe");
    waitForKeyElements (".bubble > .body > .itemMessage", onMessagesRendered, false);
}

function onMessagesRendered(jNode)
{
    jNode.click(function(){ clickMessage(); });
    stripQuotedText(jNode);
}

function clickMessage()
{
    waitForKeyElements ("#__hop_embed", stripQuotedText, false, ".messageframe");
}

function stripQuotedText (jNode)
{
    jNode.html( jNode.html().replace(QUOTED_TEXT_REGEX_DUT, "")
                            .replaceAll(DEFAULT_SIG_1,"")
                            .replaceAll(DEFAULT_SIG_2,"")
                            .replaceAll(ORIGINAL_MSG,"")
                            .replaceAll(TRAILING_NEWLINES,"")
                            .replaceAll(TRAILING_EMPTY_DIVS,""));
}