Extension methods

Extension methods grouped by the type they extend. In a ZennoPoster C# action project is IZennoPosterProjectModel and instance is Instance.

On IZennoPosterProjectModel

Summary
AddRange Inserts rows with ids from the current maximum + 1 up to range, in batches of 500.
Age Age of the session: time since the Unix milliseconds stored in var.
AnalyzeCookies Reads the current account's stored cookies and summarises them.
Bool Returns true when the project variable equals True exactly.
BuildZpFromXml Builds a .zp file from project XML, using the current project file as the container.
CatchErrorFromTraffic After a pause, finds the request to url in the traffic of the main domain and checks its JSON response.
ChooseAccountByCondition Picks an account and stores it in acc0; the candidates stay in the accs list and its row gets status = 'working...'.
ChooseAndRunByCondition Picks an account (ChooseAccountByCondition) and starts the browser for it (RunBrowser).
CleanDomainInDb Removes cookies of a domain (and, for cookies stored with a leading dot, its subdomains) from the current account's stored set.
ClmnAdd Adds a column if the table does not have it.
ClmnDrop Drops a column if it exists (CASCADE on PostgreSQL).
ClmnExist Checks whether a column exists.
ClmnList Column names of a table.
ClmnPrune Drops every column except id in which no row has a non-empty value.
ClmnRearrange Reorders columns: id first, then the columns of tableStructure that exist, then the rest.
CollectAndSave Writes one row per running ZennoPoster and zbe1 process of this machine (id `{pid}
DbClearLine Sets every column except id to an empty string in one row.
DbDone Writes a cooldown timestamp (Time.Cd, ISO UTC) to the task column of the current account's row (or the row selected by key/acc, or the rows matching where): end of today, or now plus cooldownMin.
DbGet Reads columns of one row; same as SqlGet.
DbGetColumns Reads columns of one row as column → value.
DbGetLine Reads columns of one row as an array.
DbGetLines Reads several rows; each item keeps its columns joined by ¦.
DbGetRandom Reads toGet from random rows where it is not empty and id is below range.
DbInsert Inserts one row.
DbKey Reads the current account's key from the wallet table (DbSchema.Wlt) and decrypts it with SAFU.Decode.
DbQ Executes one SQL statement against the database named by dbSource (project variable, else global variable).
DbSwapLines Exchanges the values of all columns except id between two rows.
DbToJson Rebuilds the JSON saved by JsonToDb with saveStructure from the current account's row.
DbToVars Reads columns of one row and sets a project variable of the same name for each.
DbUpd Runs UPDATE … SET toUpd for the current account's row, or for the rows matching where.
Deadline Two-call deadline based on the t0 variable.
Decimal Returns a project variable parsed as decimal (current culture), or 0 when it cannot be parsed.
DELETE Sends a DELETE request with a new Rqst; log also enables its logging.
DicToDb Writes a dictionary to the current account's row (or the rows matching where), adding missing columns first.
EnsureProcessTable Creates the _processes table if it does not exist.
EnsureTable Creates the table described by schema if it does not exist.
Finish Ends the account session: Disposer.FinishSession.
FixTime Runs BrowserScan.FixTime; an error is written to the log as a warning and does not stop the project.
FullPath Returns the full path of the project file.
GClean Clears the global variables acc1 … acc{rangeEnd}.
GenerateNative Writes the balance table of the given chains (Accountant.ShowBalanceTable with id added).
GET Sends a GET request with a new Rqst; log also enables its logging.
GetAllMachines Distinct machine names in the _processes table.
GetValuesByProperty Reads property values as text, with single quotes doubled.
GGetBusyList Lists accounts taken by running threads: every non-empty global variable acc1 … acc{rangeEnd}.
GSetAcc Marks the current account (acc0) as taken by writing input to the global variable acc{acc0}.
GVar Returns a global variable, or an empty string when it does not exist.
Help Opens a searchable API browser window.
HWPass Returns the deterministic password of the current account (acc0), using the PIN from the cfgPin secure variable.
ImproveBrowser Applies a browser profile matching the proxy's exit point, then checks the result.
InitVariables Runs Init.InitVariables and then starts the embedded server (StartZpServer).
Int Returns a project variable parsed as int, or 0 when it is empty or not a number.
JsonToDb Flattens a JSON object into columns (nested keys joined with _) and writes them with DicToDb.
KillByUptime Kills zbe1 processes running longer than maxUptimeMinutes and, when any were killed, refreshes the table.
ListFromFile Replaces the content of a ZennoPoster list with the lines of a file.
ListSync Copies a ZennoPoster list into a new List<string>.
log Writes a message to the project log through a default Logger.
MaxErr Error counter for retry loops.
MigrateAllTables Copies every user table from the current database to the other kind: PostgreSQL → SQLite or SQLite → PostgreSQL (see Sql.MigrateAllTablesAsync).
MigrateTable Copies source to a new table dest in the same database, then renames a column acc0 or key to id if there is one.
NetGet Sends a GET request through NetHttp without logging.
NetPost Sends a POST request with a JSON body through NetHttp without logging.
OtpCode One-time code from a source: for an address (contains @), the code from its latest FirstMail message; otherwise source is a TOTP secret and the current code is computed locally.
PathCookies Returns {profiles}/accounts/cookies/{acc0}.json, or an empty string with a warning when acc0 is empty.
PathProfileFolder Returns {profiles}/accounts/profilesFolder/{acc0}, or an empty string with a warning when acc0 is empty.
PathProfiles Returns the profile storage root: the profiles_folder variable, else the global variable of the same name.
POST Sends a POST request with a new Rqst; log also enables its logging.
PrepareProjectTable Array form of PrepareProjectTable(List<string>, …).
PrepareSession Loads the account's cookies (instance.GetCookies), sets the profile email to {NickName}@outlook.com and a random 12-character password, turns on traffic monitoring, sets the window to 1280×720, stores Time.Now() in ts0 and runs ImproveBrowser.
PrintCookieReport Writes the AnalyzeCookies summary to the log (top 10 domains, top 5 largest cookies).
ProjectName Returns the project file name up to the first dot and stores it in projectName.
ProjectTable Returns __ + project name and stores it in projectTable.
ProxySet Checks a proxy and applies it to the instance: compares the IP seen by public echo services directly and through the proxy, and sets the proxy only when they differ.
PruneAllCookies Runs PruneCookies on the _instance and folder_profile tables for every account from rangeStart to rangeEnd, then clears acc0.
PruneCookies Removes cookies from the current account's stored set and writes it back as Base64 JSON.
PUT Sends a PUT request with a new Rqst; log also enables its logging.
QuantityByCondition Counts the accounts matching the condition over all range groups, after the social filters.
Range Parses an account range and stores it in rangeStart, rangeEnd and range (comma-separated list).
ReadEnv Returns the value of key from a .env file, or null when the file or the key is missing.
ReportError Writes an error report (Reporter.ReportError).
ReportSuccess Writes a success report (Reporter.ReportSuccess).
RndDecimal Reads a project variable as a decimal; a value like 0.1-0.5 gives a random number in that range.
RndFromList Returns a random line of a ZennoPoster list.
RndInt Reads a project variable as an integer; a value like 10-20 gives a random integer from 10 (inclusive) to 20 (exclusive).
RndInvite Returns the cfgRefCode variable; when it is empty, picks a random non-empty inviteColumn from the project table and stores it in cfgRefCode.
RndProfileData Sets random profile data.
RunBrowser Starts the browser for the current account (InstanceManager.Initialize) and sets state = 'busy' in _instance.
RunZp Runs the project whose path is stored in the projectScript variable, via ExecuteProject.
SaveAllCookies Writes all instance cookies as Base64 to the cookies column of the current account's row.
SaveAsXml Unpacks the current project to XML (UTF-16).
SaveDebugScreenshot Saves a screenshot of the instance to {project.Path}/debug_screens/{yyyy-MM-dd}/{project.Name}/{actionId} - {unix ms}.png with a text box in the top-left corner (Iosevka 15 pt, white on dark).
SaveDomainCookies Writes the instance cookies of one domain as Base64 to the cookies column of the current account's row.
SaveProfile Exports the profile and instance properties, WebGL settings and cookies (Base64) to {project.Directory}/profiles/zenno_profile_{yyyyMMdd_HHmmss}_{id}.json.
SaveSuccessHar Saves the browser traffic to {project.Path}/har/{yyyy-MM-dd}/{result}/{project.Name}/{unix ms}.har.
SearchInZp Finds text in the actions of every .zp file in a folder (case-insensitive, in attributes and values; XML entities are decoded for matching).
SecureVar Reads a value from the encrypted jVars variable: decrypts it with SAFU.DecryptHWID, decodes Base64 and looks the key up in the resulting JSON object.
SetValuesFromDb Sets the object's writable properties from a database row, converting text to the property type.
SpoofGpu Takes a random WebGL profile (Base64 JSON per line) from {project.Path}/resourses/webgl.txt, replaces its unmasked vendor and renderer with RandomAngleString (GPU list cached in resourses/gpu.json), stores it in webgl and loads it into the instance.
SqlGet Selects columns from the row where key = id, or from the rows matching where.
SqlGetArrFromLine Like SqlGet, split into column values.
SqlGetDicFromLine Like SqlGet, returning the first row as column → value.
SqlGetListFromLines Like SqlGet, split into rows.
SqlUpd Runs UPDATE … SET toUpd for the row where key = id, or for the rows matching where.
StartSession Waits a random 0–1 s and stores the current Unix milliseconds in varSessionId.
StartZpServer Loads the access token, takes the first free port from port (up to 20 tried) and starts serving on a background thread.
StopZpServer Stops the server.
TblAdd Creates a table unless it exists.
TblColumns Column names of a table.
TblExist Checks whether a table exists.
TblForProject Builds a table layout: id INTEGER PRIMARY KEY AUTOINCREMENT, the given columns, and one column per item of the comma-separated cfgToDo variable.
TblList Names of all tables, sorted.
TblPrepareDefault Creates the project table (projectTable variable) with the TblForProject layout and adds missing columns.
TimeElapsed Seconds since the time stored (as Unix milliseconds) in a project variable.
TimeOut Throws once the session (varSessionId) is older than min minutes.
ToJson Loads JSON into project.Json.
Var Returns the value of a project variable.
VarAdd Adds a variable to the project open in ProjectMaker through the local ZennoPoster API (http://localhost:5299).
VarCounter Adds input to an integer project variable and stores the result.
VarRnd Reads a project variable.
VarsFromDict Sets a project variable for every key of the dictionary.
VarsFromJson Sets project variables from a flat JSON object of string values.
VarsMath Applies +, -, * or / to two project variables parsed as decimal (invariant culture).
warn Writes a warning to the project log.
ZB Stores toDo in the toDo variable and runs {project.Path}/.internal/ZB.zp, passing acc0, cfgLog, cfgPin, DBmode, DBpstgrPass, DBpstgrUser, DBsqltPath, instancePort, lastQuery, cookies, varSessionId and toDo by name.
ZBDbGet Reads query columns of the profile whose id is in the zb_id variable, directly from %LOCALAPPDATA%\ZennoLab\ZP8\.zp8\ProfileManagement.db.
ZBIdDic Maps profile names to ids from a JSON array of ZennoBrowser profiles (Name, Id, FolderName); for duplicate names the first wins.
ZBIdList Profile ids of a folder from a JSON array of profiles (see ZBIdDic).
ZBids Reads id and name of every ZennoBrowser profile except template from the ProfileInfos table of %LOCALAPPDATA%\ZennoLab\ZP8\.zp8\ProfileManagement.db.

On Instance

Summary
CenterArea Area [x, y, width, height] of the given size centred in the viewport.
CenterMouse Dispatches a mousemove event to the element at the centre of the window.
ClearShit Closes all tabs, clears cache and cookies of domain and opens about:blank.
ClickCenter Clicks the viewport centre; returns the point.
ClickImg Finds the image and clicks its centre.
CloseExtraTabs Closes every tab after the first tabToKeep.
CloseNewTab Waits until the number of tabs equals tabIndex and closes all but the first.
CtrlV Pastes text through the Windows clipboard (Ctrl+V); the previous clipboard text is restored.
Down Closes the browser (launches "without browser") and waits.
F5 Reloads the page.
FindAllInScreenshot Takes one page preview (GetPagePreview) and finds every occurrence of each template in the area.
FindImg Finds an image in the area with ZennoPoster's own image search.
FindImgFast Takes one page preview (GetPagePreview) and finds the image in the area with AForge template matching.
FindMultipleInMultipleAreas Takes one page preview (GetPagePreview) and finds each template in its own area.
FindMultipleInScreenshot Takes one page preview (GetPagePreview) and finds the first match of each template in the area.
FixTimezone Opens browserscan.net, takes the IP timezone from its visitor-IP request in the traffic and sets it as the instance's IANA timezone.
GetCenter Centre [x, y] of the page viewport (window.innerWidth/innerHeight).
GetCookies Collects fresh cookies from 5–15 random popular sites with CookieCollector (the profile's user agent and languages, requests sent directly without the instance proxy) and loads them into the instance.
GetCookies Reads the instance's cookies.
GetCookiesByJs Reads document.cookie of the active page as JSON (path /, no expiry; HttpOnly cookies are not visible to scripts).
GetHe Finds an element in the active tab.
Go Navigates the active tab unless it is already on the URL.
GrabTrafficList Returns the requests recorded so far whose URL matches url.
HeCatch Watches for an element that must not appear (e.g.
HeClick Waits for an element and clicks it after a random pause of about 1–1.3 s × delay.
HeDragAndDrop Drags from the element's centre by the given offset with a human-like path: easing, slight vertical wobble and, for longer moves, a small overshoot and correction.
HeDrop Waits for an element and removes it from the page.
HeGet Waits for an element and returns one of its attributes.
HeLongClick Waits for an element and holds the left button at a random point inside it.
HeMultiClick Clicks each element in turn with HeClick defaults.
HePeakRandom Opens a drop-down by two long clicks and presses Down a random number of times.
HeSet Waits for an input and enters value after a random pause of about 1.3–2 s × delay.
JsClick Finds the element by CSS selector, also inside shadow roots, scrolls it into view, focuses it and dispatches a click event.
JsGet Evaluates jsSelector to an element and returns one of its properties: any attribute, or innerText, innerHTML, textContent, value, checked, tagName.
JsPost Runs a script in the active tab.
JsSet Finds the element by CSS selector, clicks and focuses it, clears it and types value with insertText, then dispatches input and change.
MousePOsCenter Turns on full mouse emulation and puts the cursor at the viewport centre.
SaveCookies Returns the instance's cookies as saved by SaveCookie (through a temporary file).
SaveHar Writes the traffic recorded since StartHar to a HAR file.
ScrollDown Scrolls with the emulated mouse wheel.
SetCookiesByJs Sets cookies of the active tab's domain through document.cookie, for the parent domain, Secure, expiring in a year when the stored date has passed.
SetTimeFromDb Sets timezone emulation from the timezone JSON (timezoneOffset, timezoneName) of the account's _instance row; warns when there is none.
StartHar Starts HAR recording over DevTools for this instance.
StopHar Stops HAR recording for this instance.
SwipeFromCenter Swipes from the viewport centre.
SwipeImgToCenter Finds the image and swipes from it to the viewport centre.
TapCenter Taps the viewport centre; returns the point.
TapImg Finds the image and taps its centre (touch event).
UpEmpty Launches Chromium without a profile folder.
UpFromFolder Launches the browser with a profile folder.

On string

Summary
CleanFilePath Removes characters that are not allowed in file names.
ConvertUrl Shows the query parameters of a URL, one per line.
EscapeMarkdown Escapes Telegram MarkdownV2 special characters with a backslash.
FromBase64 Decodes UTF-8 Base64; empty for empty input; the input unchanged when it is not Base64.
HexToString Converts a hex number (with or without 0x) to decimal text, optionally scaling it down.
JsonToDic Flattens a JSON object: nested keys are joined with _, array items get their index (a_b_0).
ParseJwt Decodes a JWT without checking its signature.
Range Expands an account range: 1,4,7 as is, 1-10 to every number, a single number n to 1…n.
StringToHex Converts a decimal number to a 0x hex string, optionally scaling it first.
ToBase64 UTF-8 Base64 of the text; empty for empty input.

On HtmlElement

Summary
Center Centre of the element relative to origin (bounding-client size when known, else the element size).
DecodeQr Draws the element and decodes a QR code from the picture (ZXing).
GetXPath Builds an XPath for the element by walking up to body.

On Dictionary<string, string>

Summary
DicToVars Sets a project variable for every key of the dictionary.

On IList

Summary
Rnd Returns a random item.

On int

Summary
RndBool true with the given probability, in percent.