ioppermann / thunderbird-randomsignature

Thunderbird Addon. Updates a given signature file in regular intervals.
https://addons.mozilla.org/en-US/thunderbird/addon/randomsignature/
1 stars 1 forks source link

no Thunderbird 60 compatibility #3

Open se10dev opened 6 years ago

se10dev commented 6 years ago

Is there a chance for an update?

victorhck commented 4 years ago

would be great!

ioppermann commented 4 years ago

It needs to be completely rewritten to the new MailExtension API which is the only allowed way to write extenstion as of Thunderbird 78.

B00ze64 commented 4 years ago

I looked at the code and at things that got deprecated in TB60, and while some of it seems easy to fix (nsILocalFile->nsIFile and nsIPrefBranch2/nsIPrefBranchInternal->nsIPrefBranch) other stuff looks more complicated (nsIScriptableUnicodeConverter). TB68 is even worse since the XUL table is gone. I did not attempt to port it to TB60, I am not a JS dev and I would have no idea how to test this should something not work after I make changes. Instead I wrote a simple windows batch file that does the same thing and I run it in the scheduler every 5 minutes. It will do for now. Hopefully in two or three years when I update TB again, Random Signature will have a MailEx version :-)

leonardocuei commented 3 years ago

Instead I wrote a simple windows batch file that does the same thing and I run it in the scheduler every 5 minutes. It will do for now. Hopefully in two or three years when I update TB again, Random Signature will have a MailEx version :-)

How about sharing that script with us ?? :) That would be great!

B00ze64 commented 3 years ago

Sure.

What I needed was a way to add a random TagLine to a signature file; this is how I used the extension. I got several signature files, that I use for the various accounts in Thunderbird (you can tell TB to use a file instead of typing your signature in the account settings). Now all that's needed is to have a file full of TagLines, 1 per line, without the %% separators (actually without any % in it at all as batch scripts have issues with this) and run a batch script every X minutes to add a TagLine to all of the signature files.

Here I use the format "Sig-ACCOUNT-root.txt" for my signature files that do not have the tagline, and it outputs "Sig-ACCOUNT.txt" (without the ROOT suffix). I schedule this every 5 minutes. I also use a VBS script to run the batch file because otherwise a black window opens every 5 minutes. ACCOUNT can be anything; for simplicity I use the account's email address. The script below will produce 3 signatures...

Command in Task Scheduler:

PROGRAM = C:\Windows\System32\wscript.exe PARAMETERS = //B //NoLogo "D:\Mail\RandomSig.vbs"

VBS Script (RandomSig.vbs):

Dim WinScriptHost
Set WinScriptHost = CreateObject("WScript.Shell")
WinScriptHost.Run Chr(34) & "D:\Mail\RandomSig.cmd" & Chr(34), 0, True
Set WinScriptHost = Nothing

The batch file (RandomSig,cmd): The tagfile is called TagLines.txt in same folder as the signatures...

@ECHO OFF

REM $VER: RandomSig.cmd 1.1 (2020-10-06)
REM Adds a random TAGLINE to Thunderbird Signatures

SETLOCAL ENABLEEXTENSIONS

REM Skip when TB is not running
Tasklist /FI "IMAGENAME eq Thunderbird.exe" /FO CSV /NH | find /I "thunderbird.exe" >NUL
IF ERRORLEVEL 1 GOTO :EOF

REM This is where my signatures and tagfile are
CD /D D:\Mail

Set NumTags=0
FOR /F "usebackq tokens=*" %%L in ("Taglines.txt") DO SET /A NumTags+=1
REM Count the number of taglines

Call :DoSig "MyAccount@Hotmail"
Call :DoSig "MyAccount@Zoho"
Call :DoSig "MyAccount@GMail"
Goto :EOF

REM ----------------------------------------
:DoSig
REM ----------------------------------------

Call :GetTag
copy "Sig-%~1-ROOT.txt" "Sig-%~1.txt" >NUL:
>>"Sig-%~1.txt" ECHO %TagLine%
>>"Sig-%~1.txt" ECHO.
GOTO :EOF

REM ----------------------------------------
:GetTag
REM ----------------------------------------

SET R=%RANDOM%
SET /A Tag=R%%NumTags
SET /A Tag=%Tag%+1
REM Random number between 1 and how many Tags there are
REM echo %NumTags% %R% %Tag%

Set Line=0
FOR /F "usebackq tokens=*" %%L in ("Taglines.txt") DO (

    SET /A Line+=1
    SET TagLine=%%L

    SETLOCAL ENABLEDELAYEDEXPANSION
    IF !Line!==%Tag% GOTO :EOF
    ENDLOCAL
)
GOTO :EOF
ioppermann commented 3 years ago

@B00ze64 Thanks for sharing!