- Регистрация
- 04.05.2024
- Сообщения
- 638
- Реакции
- 83
- Баллы
- 28
находим формы жме продолжить, это гугле . чуть позже проверю как оно в фб он тоже подлец решит этими делами
Код:
var tab = instance.ActiveTab;
tab.SetActive();
Func<ZennoLab.CommandCenter.HtmlElement, bool> ok = e => e != null && !e.IsVoid && !e.IsNull;
Func<string, string> low = s => (s ?? "").Trim().ToLowerInvariant();
Action<ZennoLab.CommandCenter.HtmlElement> fire = e =>
{
if (!ok(e)) return;
try { e.ScrollIntoView(); } catch {}
System.Threading.Thread.Sleep(200);
try { e.Focus(); } catch {}
foreach (var ev in new [] { "mouseover", "mousedown", "mouseup", "click" }) try { e.RiseEvent(ev, instance.EmulationLevel); } catch {}
try { e.Click(); } catch {}
System.Threading.Thread.Sleep(900);
};
Action<int,int> mouse = (x,y) =>
{
try { tab.MouseMove(x, y, false, false); } catch {}
System.Threading.Thread.Sleep(120);
try { tab.MouseClick(x, y, "left", "click", false); } catch {}
System.Threading.Thread.Sleep(180);
try { tab.MouseClick(x, y, "left", "click", true); } catch {}
System.Threading.Thread.Sleep(1600);
};
Func<string, bool> pos = s =>
{
s = low(s);
foreach (var k in new [] { "accept", "agree", "allow", "continue", "next", "ok", "yes", "confirm", "consent", "got it", "akzept", "zustimm", "weiter", "fortfahren", "accepter", "accepte", "acept", "aceitar", "accetta", "прин", "соглас", "продолж", "далее", "потв", "прием", "съглас", "продъл", "hyv", "jatka", "selv", "同意", "接受", "允许" }) if (s.Contains(k)) return true;
return false;
};
Func<string, bool> neg = s =>
{
s = low(s);
foreach (var k in new [] { "reject", "decline", "deny", "cancel", "close", "more", "options", "settings", "manage", "sign in", "feedback", "ablehn", "refuser", "отхв", "отказ", "отклон", "закр", "още", "опции", "настрой", "hylk", "lis", "vaihtoe" }) if (s.Contains(k)) return true;
return false;
};
var en = tab.FindElementByXPath("//a[contains(@href,'hl=en') and contains(.,'English')]", 0);
if (ok(en)) fire(en);
var dialogs = tab.FindElementsByXPath("//*[@role='dialog']");
for (int i = dialogs.Count - 1; i >= 0; i--)
{
var d = dialogs.GetByNumber(i);
if (!ok(d)) continue;
var t = low(d.InnerText + " " + d.GetAttribute("aria-label"));
if ((t.Contains("feedback") || t.Contains("choose what")) && !t.Contains("before you continue")) try { d.ParentElement.RemoveChild(d); } catch {}
}
System.Threading.Thread.Sleep(500);
var list = tab.FindElementsByXPath("//button | //*[@role='button'] | //input[@type='submit' or @type='button'] | //a[@role='button']");
ZennoLab.CommandCenter.HtmlElement best = null;
int bestScore = -100000;
for (int i = 0; i < list.Count; i++)
{
var e = list.GetByNumber(i);
if (!ok(e)) continue;
string t = low(e.InnerText + " " + e.GetAttribute("value") + " " + e.GetAttribute("aria-label") + " " + e.GetAttribute("title") + " " + e.Id + " " + e.Name);
int score = 0;
var p = e.DisplacementInTabWindow;
if (pos(t)) score += 1000;
if (neg(t)) score -= 900;
if (p.Y > 350) score += 80;
if (p.X > 450) score += 50;
if (e.BoundingClientWidth >= 70) score += 25;
if (e.BoundingClientHeight >= 25) score += 15;
if (t.Length == 0) score -= 200;
if (score > bestScore) { bestScore = score; best = e; }
}
if (ok(best) && bestScore >= 100) fire(best);
var still = tab.FindElementByXPath("//*[@role='dialog' and contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'before you continue')]", 0);
if (ok(still))
{
mouse(846, 810);
still = tab.FindElementByXPath("//*[@role='dialog' and contains(translate(normalize-space(.),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'),'before you continue')]", 0);
if (ok(still)) try { still.SetAttribute("style", "display:none!important;visibility:hidden!important;pointer-events:none!important"); } catch {}
}
project.Variables["page_dump"].Value = "universal_accept score=" + bestScore;
project.SendInfoToLog(project.Variables["page_dump"].Value, true);



