{"id":17472713,"url":"https://github.com/shinnn/reloader-injector","last_synced_at":"2026-04-27T21:31:55.245Z","repository":{"id":57352903,"uuid":"169961053","full_name":"shinnn/reloader-injector","owner":"shinnn","description":"Insert a \u003cscript\u003e to reload the current page or its styles into an HTML","archived":false,"fork":false,"pushed_at":"2019-02-10T12:39:30.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2026-03-25T09:11:44.327Z","etag":null,"topics":["autoreload","javascript","livereload","nodejs","reload"],"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/shinnn.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":"2019-02-10T09:18:41.000Z","updated_at":"2019-02-10T12:39:32.000Z","dependencies_parsed_at":"2022-09-05T11:41:28.181Z","dependency_job_id":null,"html_url":"https://github.com/shinnn/reloader-injector","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/shinnn/reloader-injector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Freloader-injector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Freloader-injector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Freloader-injector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Freloader-injector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shinnn","download_url":"https://codeload.github.com/shinnn/reloader-injector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shinnn%2Freloader-injector/sbom","scorecard":{"id":819153,"data":{"date":"2025-08-18","repo":{"name":"github.com/shinnn/reloader-injector","commit":"345b63002b1745f2014064e41fc78e54d969011f"},"scorecard":{"version":"v5.2.1-41-g40576783","commit":"40576783fda6698350fcbbeaea760ff827433034"},"score":1.7,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#sast"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#token-permissions"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#maintained"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/3 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#code-review"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#cii-best-practices"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#fuzzing"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: ISC License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":0,"reason":"38 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92","Warn: Project is vulnerable to: GHSA-6chw-6frg-f759","Warn: Project is vulnerable to: GHSA-v88g-cgmw-v5xw","Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw","Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25","Warn: Project is vulnerable to: GHSA-v6h2-p8h4-qcjw","Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275","Warn: Project is vulnerable to: GHSA-gxpj-cx7g-858c","Warn: Project is vulnerable to: GHSA-3gx7-xhv7-5mx3","Warn: Project is vulnerable to: GHSA-q42p-pg8m-cqh6","Warn: Project is vulnerable to: GHSA-w457-6q6x-cgp9","Warn: Project is vulnerable to: GHSA-62gr-4qp9-h98f","Warn: Project is vulnerable to: GHSA-f52g-6jhx-586p","Warn: Project is vulnerable to: GHSA-2cf5-4w76-r9qv","Warn: Project is vulnerable to: GHSA-3cqr-58rm-57f8","Warn: Project is vulnerable to: GHSA-g9r4-xpmj-mj65","Warn: Project is vulnerable to: GHSA-q2c6-c6pm-g3gh","Warn: Project is vulnerable to: GHSA-765h-qjxv-5f44","Warn: Project is vulnerable to: GHSA-f2jv-r9rf-7988","Warn: Project is vulnerable to: GHSA-43f8-2h32-f4cj","Warn: Project is vulnerable to: GHSA-2pr6-76vf-7546","Warn: Project is vulnerable to: GHSA-8j8c-7jfh-h6hx","Warn: Project is vulnerable to: GHSA-jg8v-48h5-wgxg","Warn: Project is vulnerable to: GHSA-36fh-84j7-cv5h","Warn: Project is vulnerable to: GHSA-6c8f-qphg-qjgp","Warn: Project is vulnerable to: GHSA-jf85-cpcp-j695","Warn: Project is vulnerable to: GHSA-p6mc-m468-83gw","Warn: Project is vulnerable to: GHSA-29mw-wpgm-hmr9","Warn: Project is vulnerable to: GHSA-35jh-r3h4-6jhm","Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3","Warn: Project is vulnerable to: GHSA-vh95-rmgr-6w4m","Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h","Warn: Project is vulnerable to: GHSA-hj48-42vr-x3v9","Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw","Warn: Project is vulnerable to: GHSA-52f5-9888-hmc6","Warn: Project is vulnerable to: GHSA-776f-qx25-q3cc","Warn: Project is vulnerable to: GHSA-c4w7-xm78-47vh","Warn: Project is vulnerable to: GHSA-p9pc-299p-vxgp"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/40576783fda6698350fcbbeaea760ff827433034/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-23T14:56:46.163Z","repository_id":57352903,"created_at":"2025-08-23T14:56:46.163Z","updated_at":"2025-08-23T14:56:46.163Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["autoreload","javascript","livereload","nodejs","reload"],"created_at":"2024-10-18T17:34:31.622Z","updated_at":"2026-04-27T21:31:55.220Z","avatar_url":"https://github.com/shinnn.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# reloader-injector\n\n[![npm version](https://img.shields.io/npm/v/reloader-injector.svg)](https://www.npmjs.com/package/reloader-injector)\n[![Build Status](https://travis-ci.com/shinnn/reloader-injector.svg?branch=master)](https://travis-ci.com/shinnn/reloader-injector)\n[![Build status](https://ci.appveyor.com/api/projects/status/g5wgg0nx4pyifim3/branch/master?svg=true)](https://ci.appveyor.com/project/ShinnosukeWatanabe/reloader-injector/branch/master)\n[![codecov](https://codecov.io/gh/shinnn/reloader-injector/branch/master/graph/badge.svg)](https://codecov.io/gh/shinnn/reloader-injector)\n\nA [Node.js](https://nodejs.org/) module to insert a `\u003cscript\u003e` into an HTML, which helps reloading the document or its styles automatically\n\n*In most cases there is no need to use this module directly. Developers would rather use a higher-level wrapper [`content-reloader`](https://github.com/shinnn/content-reloader).*\n\n## Installation\n\n[Use](https://docs.npmjs.com/cli/install) [npm](https://docs.npmjs.com/about-npm/).\n\n```\nnpm install --save-dev reloader-injector\n```\n\n## API\n\n```javascript\nconst ReloaderInjector = require('reloader-injector');\n```\n\n### class ReloaderInjector([*option*])\n\n*option*: `Object`  \n\nIt creates an `reloaderInjector` instance.\n\n#### option.url\n\nType: `string` `URL`  \nDefault: `'/sse'`\n\nA URL at which the client script will [open a connection](https://developer.mozilla.org/en-US/docs/Web/API/EventSource/EventSource) to the server.\n\nThis module expects the server to serve no contents other than `reloader-injector`-related ones under this URL. If the server will respond to requests whose URLs begin with `/sse`, change the value of this option.\n\n### reloaderInjector.injectScriptTag(*response*)\n\n*response*: [`http.ServerResponse`](https://nodejs.org/api/http.html#http_class_http_serverresponse)\n\nIf the media type of the response is `text/html`, it inserts a `\u003cscript\u003e` tag into the response body as the first child of `\u003cbody\u003e`. The `src` attribute of the `\u003cscript\u003e` points to the first key of [`reloaderInjector.clients`](#reloaderinjectorclients).\n\n### reloaderInjector.injectLegacyScriptTag(*response*)\n\n*response*: `http.ServerResponse`\n\nIf the media type of the response is `text/html`, it inserts a `\u003cscript\u003e` tag into the response body as the first child of `\u003cbody\u003e`. The `src` attribute of the `\u003cscript\u003e` points to the second key of `reloaderInjector.clients`.\n\n### reloaderInjector.clients\n\nType: `Map\u003cstring: Buffer\u003e`\n\nThis `Map` contains two [`Buffer`](https://nodejs.org/api/buffer.html#buffer_class_buffer)s: the first value is a JavaScript code generated by [the main function](https://github.com/shinnn/reloader-client#reloaderclienturl) of [`reloader-client`](https://github.com/shinnn/reloader-client), and the second one is a JavaScript code generated by the [`.legacy()`](https://github.com/shinnn/reloader-client#reloaderclientlegacyurl) method of `reloader-client`.\n\n### reloaderInjector.path\n\nType: `string`\n\nA [pathname](https://developer.mozilla.org/en-US/docs/Web/API/URL/pathname) of the URL corresponding to the `url` option.\n\n```javascript\nconst reloaderInjector = new ReloaderInjector();\n\nreloaderInjector.clients; /*=\u003e Map {\n  '/sse-95f0ec37f24542c2547b712a060e43af.js' =\u003e \u003cBuffer 63 6f 6e 73 ...\u003e,\n  '/sse-eb33250679b5d5c862ed2286a2c95e75.js' =\u003e \u003cBuffer 2f 2a 2a 20 ...\u003e\n} */\n```\n\n### ReloaderInjector.DOCUMENT_RELOAD_SIGNAL, ReloaderInjector.CSS_RELOAD_SIGNAL\n\nType: `string`\n\nThe same values as [`reloader-client`'s](https://github.com/shinnn/reloader-client#reloaderclientdocument_reload_signal).\n\n## Usage\n\n__1.__ Inject a `\u003cscript\u003e` tag to an HTML `Response` using `.injectScriptTag()` (or `.injectLegacyScriptTag()` for Microsoft browsers).\n\n```javascript\nconst reloaderInjector = new ReloaderInjector();\n\nconst server = createServer(({url}, res) =\u003e {\n  res.setHeader('content-type', 'text/html');\n  reloaderInjector.injectScriptTag(res);\n  res.end('\u003c!doctype html\u003e\u003chtml lang=\"en\"\u003e ... some contents ... \u003c/html\u003e');\n});\n```\n\n__2.__ Serve JavaScript of `reloaderInjector.clients` using its keys as a `pathname` of endpoints.\n\n```diff\nconst server = createServer(({url}, res) =\u003e {\n+   for (const [clientUrl, body] of reloaderInjector.clients) {\n+     if (url === clientUrl) {\n+       res.writeHead(200, {\n+         'content-type': 'application/javascript',\n+         'content-length': body.length\n+       });\n+\n+       res.end(body);\n+       return;\n+     }\n+   }\n```\n\n__3.__ Whenever a reload should be performed, send a [server-sent event](https://developer.mozilla.org/en-US/docs/Web/API/Server-sent_events) to the client in the following form:\n\n```\nid: \u003cany\u003e\ndata: \u003cReloaderInjector.DOCUMENT_RELOAD_SIGNAL|ReloaderInjector.CSS_RELOAD_SIGNAL\u003e\n```\n\n* `data` must equal to either [`ReloaderInjector.DOCUMENT_RELOAD_SIGNAL` or `ReloaderInjector.CSS_RELOAD_SIGNAL`](#reloaderinjectordocument_reload_signal-reloaderinjectorcss_reload_signal).\n* `id` must be different from the previous event's.\n\n## License\n\n[ISC LICENSE](./LICENSE) © 2019 Shinnosuke Watanabe\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Freloader-injector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshinnn%2Freloader-injector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshinnn%2Freloader-injector/lists"}