diff --git a/Introduction-to-basic-filtering-syntax.md b/Introduction-to-basic-filtering-syntax.md new file mode 100644 index 0000000..8b4ad74 --- /dev/null +++ b/Introduction-to-basic-filtering-syntax.md @@ -0,0 +1,23 @@ +## Cosmetic filtering + +Example DOM tree: + +
+
+ +- `##` - this is always present in cosmetic filters - this means this is cosmetic filter +- `##div` - selecting by element type +- `###unique-identifier` - selecting by `id`, `##` + `#` - this should be very efficient, because there should be only one unique identifier for page +- `##.first-class` - selecting by `class`, `##` + `.` - will match other elements with same class, so: +- `##.first-class.second-class` - use both classes to select only first line from example DOM. + +Using dot for classes automatically split value of the class attribute on space characters. + +Selecting by attribute: + +- `##[data-storage="123-456"]` - will match exactly +- `##[data-storage^="123-"]` - will match from the beginning +- `##[data-storage$="-456"]` - will match from the end +- `##[data-storage*="3-4"]` - will match in the middle +- `##[id="unique-identifier"]` equivalent of `###unique-identifier` +- `##[class="first-class"]` equivalent of `##.first-class`, but will match only second line from example DOM - class attribute is compared literally, no splitting on space characters. \ No newline at end of file