


procedure TForm1.Button1Click(Sender: TObject);
begin
// opens the feeds of FarmVille only
EmbeddedWb1.Go('http://www.facebook.com/home.php?filter=app_102452128776');
// saves the feeds in to a memo
EmbeddedWb1.SaveToStrings(Memo1.Lines);
// adopts the black sheep if any found
AdoptBlackSheep(Memo1.Lines.Text);
end;


unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, OleCtrls, SHDocVw_EWB, EwbCore, EmbeddedWB, IEParser,
ExtCtrls;
type
TForm1 = class(TForm)
EmbeddedWB1: TEmbeddedWB;
Memo1: TMemo;
Button1: TButton;
GroupBox1: TGroupBox;
CheckBoxPinkCow: TCheckBox;
CheckBoxBrownCow: TCheckBox;
CheckBoxBlackSheep: TCheckBox;
CheckBoxUglyDuck: TCheckBox;
IEParser1: TIEParser;
Timer1: TTimer;
Button2: TButton;
ButtonStop: TButton;
ButtonReload: TButton;
Bevel1: TBevel;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure IEParser1Anchor(Sender: TObject; hRef, Target, Rel, Rev, Urn,
Methods, Name, Host, HostName, PathName, Port, Protocol, Search, Hash,
AccessKey, ProtocolLong, MimeType, NameProp: string;
Element: TElementInfo);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure ButtonStopClick(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure ButtonReloadClick(Sender: TObject);
private
{ Private declarations }
function Visited(beta_url: String): Boolean;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
uses ShellAPI;
{$R *.dfm}
var
Visited_links: Array[0..55] of String;
Link_Cnt: Integer;
function TForm1.Visited(beta_url: string): Boolean;
var
i: Integer;
flag_bool: Boolean;
begin
flag_bool:= False; i:= 0;
while (not flag_bool) and (i < 56) do
begin
if Visited_links[i] = 'alpha' then i:= 55;
if beta_url = Visited_links[i] then flag_bool:= True;
inc(i);
end;
Result:= flag_bool;
end;
// *********************************************************************
// *
// * FarmVille publishes two different anchors for the same object.
// *
// * Each time an animal or reward is found, two calls to ShellExecute
// * will be done. This is because there is an anchor for the image and
// * an anchor for the text.
// *
// *********************************************************************
procedure TForm1.IEParser1Anchor(Sender: TObject; hRef, Target, Rel, Rev, Urn,
Methods, Name, Host, HostName, PathName, Port, Protocol, Search, Hash,
AccessKey, ProtocolLong, MimeType, NameProp: string; Element: TElementInfo);
begin
if (CheckBoxPinkCow.Checked = True) and (Pos('cow_pink', hRef) > 0) then
begin
Memo1.Lines.Add(#13#10 + 'link for pink cow : ');
Memo1.Lines.Add(#13#10 + 'hRef: ' + hRef);
if not Visited(hRef) then
begin
{ open a web page }
ShellExecute(Handle, 'open', Pchar(hRef), nil, nil, SW_SHOWNORMAL);
Visited_links[Link_Cnt]:= hRef; inc(Link_Cnt);
if Link_Cnt > 55 then Link_Cnt:= 0;
end;
end; // if pink cow
if (CheckBoxBrownCow.Checked = True) and (Pos('cow_brown', hRef) > 0) then
begin
Memo1.Lines.Add(#13#10 + 'link for brown cow : ');
Memo1.Lines.Add(#13#10 + 'hRef: ' + hRef);
if not Visited(hRef) then
begin
{ open a web page }
ShellExecute(Handle, 'open', Pchar(hRef), nil, nil, SW_SHOWNORMAL);
Visited_links[Link_Cnt]:= hRef; inc(Link_Cnt);
if Link_Cnt > 55 then Link_Cnt:= 0;
end;
end; // if brown cow
if (CheckBoxBlackSheep.Checked = True) and (Pos('sheep_black', hRef) > 0) then
begin
Memo1.Lines.Add(#13#10 + 'link for black sheep : ');
Memo1.Lines.Add(#13#10 + 'hRef: ' + hRef);
if not Visited(hRef) then
begin
{ open a web page }
ShellExecute(Handle, 'open', Pchar(hRef), nil, nil, SW_SHOWNORMAL);
Visited_links[Link_Cnt]:= hRef; inc(Link_Cnt);
if Link_Cnt > 55 then Link_Cnt:= 0;
end;
end; // if black sheep
if (CheckBoxUglyDuck.Checked = True) and (Pos('uglyduck', hRef) > 0) then
begin
Memo1.Lines.Add(#13#10 + 'link for ugly duckling : ');
Memo1.Lines.Add(#13#10 + 'hRef: ' + hRef);
if not Visited(hRef) then
begin
{ open a web page }
ShellExecute(Handle, 'open', Pchar(hRef), nil, nil, SW_SHOWNORMAL);
Visited_links[Link_Cnt]:= hRef; inc(Link_Cnt);
if Link_Cnt > 55 then Link_Cnt:= 0;
end;
end; // if ugly duckling
// ********************* get coins ***********************************
if Pos('reward', hRef) > 0 then
if not Visited(hRef) then
begin
{ open a web page }
Memo1.Lines.Add(#13#10 + '$$$ coinage $$$');
ShellExecute(Handle, 'open', Pchar(hRef), nil, nil, SW_SHOWNORMAL);
Visited_links[Link_Cnt]:= hRef; inc(Link_Cnt);
if Link_Cnt > 55 then Link_Cnt:= 0;
end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
IEParser1.Parse('http://www.facebook.com/home.php?filter=app_102452128776');
Application.ProcessMessages;
Memo1.Lines.Add('--- 50-second interval started ---');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Button1.Enabled:= False; ButtonStop.Enabled:= True;
// IEParser1.Parse('http://www.facebook.com/home.php?filter=app_102452128776');
Timer1.Enabled:= True;
Memo1.Lines.Add('Timer started.' + #13#10);
// adopts the black sheep if any found
// AdoptBlackSheep(Memo1.Lines.Text);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Memo1.Clear;
end;
procedure TForm1.ButtonReloadClick(Sender: TObject);
begin
// opens the feed of FarmVille only
EmbeddedWb1.Go('http://www.facebook.com/home.php?filter=app_102452128776');
end;
procedure TForm1.ButtonStopClick(Sender: TObject);
begin
IEParser1.Stop;
Timer1.Enabled:= False; Button1.Enabled:= True; ButtonStop.Enabled:= False;
end;
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
EmbeddedWb1.Free; IEParser1.Free;
Timer1.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
begin
Link_Cnt:= 0;
// initialize string array
for i := 0 to 25 do Visited_links[i]:= 'alpha';
// opens the feeds of FarmVille only
EmbeddedWb1.Go('http://www.facebook.com/home.php?filter=app_102452128776');
end;
end.


Users browsing this forum: No registered users and 0 guests