{"id":20513848,"url":"https://github.com/webreflection/basic-devtools","last_synced_at":"2025-04-14T00:01:33.821Z","repository":{"id":60780713,"uuid":"545502119","full_name":"WebReflection/basic-devtools","owner":"WebReflection","description":"Exports `$`, `$$`, and `$x` utilities as described in Chrome Console Utilities API reference","archived":false,"fork":false,"pushed_at":"2023-04-26T10:17:24.000Z","size":83,"stargazers_count":21,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-27T14:11:09.574Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WebReflection.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2022-10-04T13:37:50.000Z","updated_at":"2024-09-02T13:21:10.000Z","dependencies_parsed_at":"2024-02-01T16:28:10.796Z","dependency_job_id":"920400f5-2778-4036-bcee-fb2747f6a042","html_url":"https://github.com/WebReflection/basic-devtools","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fbasic-devtools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fbasic-devtools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fbasic-devtools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WebReflection%2Fbasic-devtools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WebReflection","download_url":"https://codeload.github.com/WebReflection/basic-devtools/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248799931,"owners_count":21163403,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-15T21:13:31.485Z","updated_at":"2025-04-14T00:01:33.741Z","avatar_url":"https://github.com/WebReflection.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# basic-devtools\n\n[![Coverage Status](https://coveralls.io/repos/github/WebReflection/basic-devtools/badge.svg?branch=main)](https://coveralls.io/github/WebReflection/basic-devtools?branch=main) [![build status](https://github.com/WebReflection/basic-devtools/actions/workflows/node.js.yml/badge.svg)](https://github.com/WebReflection/basic-devtools/actions)\n\n\u003csup\u003e**Social Media Photo by [Basic Moto France](https://unsplash.com/@basic_moto) on [Unsplash](https://unsplash.com/)**\u003c/sup\u003e\n\nExports `$`, `$$`, and `$x` utilities as described in [Chrome Console Utilities API reference](https://developer.chrome.com/docs/devtools/console/utilities/), all in 242 bytes once \"*minzipped*\" or 206 bytes once \"*minbrotlied*\".\n\n```js\nimport {$, $$, $x} from 'basic-devtools';\n\n// single node\n$('nope') === null;                 // true\n$('body') === document.body;        // true\n\n// list of nodes\n$$('body').length === 1;            // true\n$$('body')[0] === document.body;    // true\n\n// list of evaluated nodes\n$x('//body').length === 1;          // true\n$x('//body')[0] === document.body;  // true\n```\n\n### What's the deal with XPath?\n\nIt's extremely powerful but also generally faster than a *TreeWalker*, as you can [**test live**](https://webreflection.github.io/basic-devtools/test/).\n\nAs example, let's consider this **Question**:\n\n\u003e \"_How would I grab all data-* attributes and reach their element with a single-pass query?_\"\n\n**Answer**\n\n```js\n// grab all nodes with data-* attributes\nconst allDataAttributes = $x('//@*[starts-with(name(), \"data-\")]');\n\n// loop all returned attributes and do something\nfor (const {name, value, ownerElement} of allDataAttributes) {\n  // ownerElement is the element using data-* attribute\n  // name is the data-* attribute name\n  // value is its value\n}\n```\n\nYou can have a gist of various other features via this awesome [Xpath cheatsheet](https://devhints.io/xpath).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fbasic-devtools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebreflection%2Fbasic-devtools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebreflection%2Fbasic-devtools/lists"}