use crate::graph::FrameId;
pub type HtmlElementId = usize;
pub type ScriptId = usize;
pub type Url = String;
pub type HtmlTag = String;
pub type HtmlAttr = String;
#[derive(Clone, PartialEq, Debug, serde::Serialize)]
pub enum NodeType {
Resource {
url: String
},
WebApi {
method: String
},
JsBuiltin {
method: String
},
HtmlElement {
tag_name: HtmlTag,
is_deleted: bool,
node_id: HtmlElementId,
},
TextNode {
text: Option<String>,
is_deleted: bool,
node_id: HtmlElementId,
},
DomRoot {
url: Option<Url>,
tag_name: HtmlTag,
is_deleted: bool,
node_id: HtmlElementId,
},
FrameOwner {
tag_name: HtmlTag,
is_deleted: bool,
node_id: HtmlElementId,
},
LocalStorage {},
SessionStorage {},
CookieJar {},
Script {
url: Option<Url>,
script_type: String,
script_id: ScriptId,
source: String,
},
Parser {},
Binding {
binding: String,
binding_type: String,
},
BindingEvent {
binding_event: String,
},
RemoteFrame {
frame_id: FrameId,
},
AdFilter {
rule: String
},
TrackerFilter, FingerprintingFilter, Storage {},
BraveShields {},
AdsShield {},
TrackersShield {},
JavascriptShield {},
FingerprintingShield {},
FingerprintingV2Shield {},
Extensions {},
}
#[derive(Clone, PartialEq, Debug)]
#[derive(serde::Serialize)]
pub enum RequestType {
Image,
Script,
CSS,
AJAX,
Unknown,
}
impl From<&str> for RequestType {
fn from(v: &str) -> Self {
match v {
"Image" => Self::Image,
"Script" => Self::Script,
"CSS" => Self::CSS,
"AJAX" => Self::AJAX,
"Unknown" => Self::Unknown,
_ => Self::Unknown,
}
}
}
impl RequestType {
pub fn as_str(&self) -> &'static str {
match self {
Self::Image => "image",
Self::Script => "script",
Self::CSS => "stylesheet",
Self::AJAX => "xhr",
Self::Unknown => "unknown",
}
}
}
#[derive(Clone, PartialEq, Debug)]
#[derive(serde::Serialize)]
pub enum EdgeType {
CrossDom {},
TextChange {},
RemoveNode {},
DeleteNode {},
InsertNode {
parent: HtmlElementId,
before: Option<HtmlElementId>,
},
CreateNode {},
JsResult {
value: Option<String>
},
JsCall {
args: Option<String>,
script_position: usize,
},
RequestComplete {
resource_type: String,
status: String,
value: Option<String>,
response_hash: Option<String>,
request_id: usize,
headers: String,
size: String,
},
RequestError {
status: String,
request_id: usize,
value: Option<String>,
headers: String,
size: String,
},
RequestStart {
request_type: RequestType,
status: String,
request_id: usize,
},
RequestResponse, AddEventListener {
key: String,
event_listener_id: usize,
script_id: ScriptId,
},
RemoveEventListener {
key: String,
event_listener_id: usize,
script_id: ScriptId,
},
EventListener {
key: String,
event_listener_id: usize,
},
StorageSet {
key: String,
value: Option<String>,
},
StorageReadResult {
key: String,
value: Option<String>,
},
DeleteStorage {
key: String
},
ReadStorageCall {
key: String
},
ClearStorage {
key: String
},
ExecuteFromAttribute {
attr_name: HtmlAttr
},
Execute {},
SetAttribute {
key: HtmlAttr,
value: Option<String>,
is_style: bool,
},
DeleteAttribute {
key: HtmlAttr,
is_style: bool,
},
Binding {},
BindingEvent {
script_position: usize,
},
Filter {},
Structure {},
Shield {},
ResourceBlock {},
StorageBucket {},
}