{"id":15542102,"url":"https://github.com/lifeart/dom-snapshot","last_synced_at":"2025-04-23T17:11:32.071Z","repository":{"id":48309360,"uuid":"99624351","full_name":"lifeart/dom-snapshot","owner":"lifeart","description":"JS methods to serialize HTML page to JSON and restore it","archived":false,"fork":false,"pushed_at":"2021-08-02T10:15:55.000Z","size":427,"stargazers_count":39,"open_issues_count":18,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-02T12:21:12.160Z","etag":null,"topics":["css","dom","html","javascript","serialize-html-page","snapshot","testing-tools"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lifeart.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}},"created_at":"2017-08-07T22:02:30.000Z","updated_at":"2024-09-11T01:50:55.000Z","dependencies_parsed_at":"2022-08-24T04:20:51.909Z","dependency_job_id":null,"html_url":"https://github.com/lifeart/dom-snapshot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifeart%2Fdom-snapshot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifeart%2Fdom-snapshot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifeart%2Fdom-snapshot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lifeart%2Fdom-snapshot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lifeart","download_url":"https://codeload.github.com/lifeart/dom-snapshot/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250477811,"owners_count":21437049,"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":["css","dom","html","javascript","serialize-html-page","snapshot","testing-tools"],"created_at":"2024-10-02T12:20:41.285Z","updated_at":"2025-04-23T17:11:32.050Z","avatar_url":"https://github.com/lifeart.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DomSnapshot\nJS methods to serialize rendered HTML page to JSON and restore it.\nJS library for browser-render HTML page serialization (with firebase support)\nJS * deserialization supported.\n\n# Use cases?\n- Grab all CSS from page!\n- Calc page diffs between renders!\n\n# Usage\n```html\n  \u003cscript src=\"https://gitcdn.xyz/cdn/lifeart/dom-snapshot/master/dist/index.js\"\u003e\u003c/script\u003e\n  // or\n  \u003cscript src=\"https://cdn.jsdelivr.net/gh/lifeart/dom-snapshot/dist/index.js\"\u003e\u003c/script\u003e\n  // or use this gh repo\n\n```\n\nBy default DomSnapshot configured to use demo firebase api to manage snapshots\n```javascript\n\tconst snapshot = new DomSnapshot();\n\t// waiting for firebase initialization\n\tsnapshot.loaded().then(()=\u003e{\n\t        // saving current DOM as snapshot\n\t\tconst id = snapshot.saveSnapshot();\n\t\tconsole.log('snapshotId', id);\n\t\tsetTimeout(() =\u003e {\n\t\t\tconsole.log('restoring current snapshot');\n\t\t\tsnapshot.showSnapshot(id)\n\t\t}, 3000);\n\t});\n\n\n```\n\n\"Offline\" usage example (without firebase sync)\n\n```javascript\n\t\n\tvar selector  = '#readme \u003e article \u003e pre';\n\n\tvar s1 = snapshoter.takeSnapshot(selector);\n\n\tdocument.querySelector(selector).style['fontSize'] = '20px';\n\tdocument.querySelector(selector).setAttribute('foo', 'bar');\n\tvar s2 = snapshoter.takeSnapshot(selector);\n\n\tvar diff = snapshoter.getSnapshotsDiff(s1, s2);\n\n\tconsole.log(diff);\n\n\t// capture node and send it to server\n\tsnapshoter.saveSnapshot(Date.now(), snapshoter.createSnapshot('body'))\t\n```\n\n# Methods\n`saveSnapshot()` - save current web-page as snapshot to firebase / _return snapshot id_\n\n`showSnapshot(id)` - restore page snapshot by id from firebase / _return snapshot object_\n\n\n# Viwer\nAn SPA for snapshots preview\n\n[dom-snapshot-ui](https://github.com/lifeart/dom-snapshot-ui)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifeart%2Fdom-snapshot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flifeart%2Fdom-snapshot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flifeart%2Fdom-snapshot/lists"}