CustomizeUserAgentRandom include
From 40tude Dialog Wiki
Contents |
Customize User-Agent at Random (Include)
This CustomizeUserAgentRandom-script is a little script done by Thomas Barghahn and modify by Maik Prinz. With this script you are able to change any header and add a trailing text at the end of the Header (IMHO its only reasonable for the User-Agent string). If you found bugs feel free to contact the autor Thomas Barghahn (Th.Barghahn@t-online.de) or Maik Prinz (2prinz@gmx.de).
Example with User-Agent-Header:
"User-Agent: 40tude_Dialog/2.0.15.1de (1643fe98.355.147) (My Newsreader No.1)"
Introduction
For the latest version of CustomizeUserAgentRandom, you need a DLL-file which provides some features like generating the random element of the MID. This DLL-file is available at http://www.nicohaase.de/dExt.dll. This file must be saved in the root of your Dialog-installation.
Install & setup the script
Please note that this script is an include-file!. You have to copy the following script inside a new custom script (for example "Include_CustomizeUserAgentRandom") and safe it. Please don't compile this custom script! After that you have to add the following lines to your OnBeforeSending-Script:
{$I Include_ChangeAnyHeaderRandom.ds}
and
result := result and ChangeAnyHeaderRandom ( Message, IsEmail );
This may look like this:
program OnBeforeSendingMessage;
{$I Include_ChangeAnyHeaderRandom.ds}
function OnBeforeSendingMessage(var Message: TStringlist; Servername: string; IsEmail: boolean):boolean;
begin
result:=true;
//possibly some other calls to scripts
result := result and ChangeAnyHeaderRandom ( Message, IsEmail );
end;
begin
end.
Just compile this OnBeforeSending-Script now to get your include-file to work. The setup of the script is shown inside the script. Please take a look at this to customize the script to your own fits. Please note that whenever you reconfigure the ChangeAnyHeaderRandom custom script, you have to recompile the OnBeforeSending-Script to apply the changes.
The Include-File
Please be sure that this is the only content in the include-file!
// Date: 2005/05/18
procedure Init_ChangeAnyHeaderRandom ( var DialogOrdner : String;
var MaxRandomKey : integer;
var ChangeHeader : String;
var AddOnChangeHeader : String;
var ChangeInEmails : Boolean;
var ChangeInNews : Boolean;
var AddOnChangeRandom : Boolean
);
begin
// ----------------------------------------------------
// Configuration settings
// ----------------------------------------------------
// set the header you want to change here, e.g. 'User-Agent'
ChangeHeader := 'User-Agent:';
AddOnChangeHeader := ' (Simply the best usenet experience)';
// 'true' erzeugt einen Zufälligen AddOnChangeHeader aus der ChangeAgentAdd.ini
AddOnChangeRandom := true;
// Pfad von Dialog in dem die Datei ChangeAgentAdd.ini enthalten ist
DialogOrdner := 'c:\programme\40tude dialog\';
// Anzahl der Einträge in ChangeAgentAdd.ini
MaxRandomKey := 10
// change header in emails and/or postings
// set 'true' or 'false'
ChangeInEmails := false;
ChangeInNews := true;
// ----------------------------------------------------
// End of configuration settings
// ----------------------------------------------------
end;
// --------------------------------------------------------------- //
// ---- No user maintainable parts below this line -------------- //
// --------------------------------------------------------------- //
function ChangeAnyHeaderRandom_MessageBox( hWnd : Cardinal; lpText, lpCaption : PChar; uType : longword ) : Integer;
external 'MessageBoxA@user32.dll stdcall';
function randomNumber( max : integer ) : integer; external 'randomNumber@dExt.dll';
procedure dateicheck ( dateiname: string ); external 'legeDateiAn@dExt.dll';
function ChangeAnyHeaderRandom(var Message:TStringlist;IsEmail:boolean) : boolean;
var i : integer;
s : String;
ChangeHeader : String;
AddOnChangeHeader : String;
ChangeInEmails : Boolean;
ChangeInNews : Boolean;
AddOnChangeRandom : Boolean;
FileStringList : TStringList;
DialogOrdner : string;
keyrandom : string;
MaxRandomKey : integer;
begin
Init_ChangeAnyHeaderRandom ( DialogOrdner, MaxRandomKey, ChangeHeader, AddOnChangeHeader, ChangeInEmails, ChangeInNews, AddOnChangeRandom );
keyrandom := inttostr(randomNumber(MaxRandomKey)+1)
if (DirectoryExists(DialogOrdner) = false) then
begin
ChangeAnyHeaderRandom_MessageBox(0,'Der Ordner ' + DialogOrdner + ' existiert nicht! Bitte ändere die Einstellung "DialogOrdner" im Script z.B. in ' + GetCurrentDir()
+ ' (Kompilieren des ChangeAnyHeaderRandom-Scriptes nicht vergessen!) oder leg den Ordner an, damit '
+ 'ChangeAnyHeaderRandom richtig arbeiten kann. Die Nachricht wird in der Outbox gespeichert und kann nach Behebung '
+ 'des Fehlers problemlos versandt werden.', 'Fehler in ChangeAnyHeaderRandom: Ordner existiert nicht', 48+4096+0);
Result := false;
end
else
begin
if (FileExists(DialogOrdner + 'ChangeAgentAdd.ini') = false) then
begin
dateicheck ( DialogOrdner + 'ChangeAgentAdd.ini' );
FileStringList := TStringList.create;
FileStringList.Clear;
FileStringList.Add('1=(Guided Consideration)')
FileStringList.Add('2=(IMHO the best User-Agent)')
FileStringList.Add('3=(the best usenet experience!)')
FileStringList.Add('4=(Free Windows-Newsreader)')
FileStringList.Add('5=(Newsreader with Unicode-Support)')
FileStringList.Add('6=( www.40tude.com/dialog/ )')
FileStringList.Add('7=( news:de.comm.software.40tude-dialog )')
FileStringList.Add('8=(Crying with the cats.)')
FileStringList.Add('9=(Dressed to kill)')
FileStringList.Add('10=(My Newsreader No.1)')
FileStringList.SaveToFile(DialogOrdner + 'ChangeAgentAdd.ini');
WriteToLog ( 'Eine neue Datei wurde erstellt' ,4);
ChangeAnyHeaderRandom_MessageBox(0, 'Eine neue Datei ' + DialogOrdner + ' mit 10 User-Agend-Addons wurde erstellt! '
+ 'Sie konnen den Inhalt jederzeit nach eigenen Bedürfnissen anpassen. '
+ 'Beim hinzufügen von Einträgen ist der Wert von MaxRandomKey im ChangeAnyHeaderRandom-Script '
+ 'entsprechend anzupassen. Die Nachricht wird jetzt verschickt.', 'ChangeAnyHeaderRandom: Datei wurde erstellt', 64+4096+0);
FileStringList := TStringList.create;
FileStringList.LoadFromFile(DialogOrdner + 'ChangeAgentAdd.ini');
end
else
begin
FileStringList := TStringList.create;
FileStringList.LoadFromFile(DialogOrdner + 'ChangeAgentAdd.ini');
end
if AddOnChangeRandom then AddOnChangeHeader := ' ' + FileStringList.Values[keyrandom]
if ((IsEmail=true) and (ChangeInEmails=true)) or
((IsEmail=false) and (ChangeInNews=true)) then begin
s := Message.text;
i := 1;
while (Message.Strings[i]<>'') do begin
if pos(ChangeHeader,Message.Strings[i]) = 1 then begin
Message.Strings[i] := Message.Strings[i] + AddOnChangeHeader;
s := Message.text;
end;
i := i + 1;
end; {end of while}
message.text := s;
end;
result := true;
end;
end;
Maik Prinz May 2005