{"id":46349640,"url":"https://github.com/grezniczek/redcap_javascript_injector","last_synced_at":"2026-03-04T22:32:43.694Z","repository":{"id":126987005,"uuid":"177769764","full_name":"grezniczek/redcap_javascript_injector","owner":"grezniczek","description":"A REDCap External Module that allows injection of JavaScript on pages.","archived":false,"fork":false,"pushed_at":"2025-05-14T14:03:59.000Z","size":97,"stargazers_count":7,"open_issues_count":0,"forks_count":7,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-09-05T05:48:06.424Z","etag":null,"topics":["redcap","redcap-external-module","redcap-repo"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grezniczek.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2019-03-26T10:55:28.000Z","updated_at":"2025-05-14T14:04:02.000Z","dependencies_parsed_at":"2024-04-21T20:57:44.018Z","dependency_job_id":"8c94d215-8431-4be8-abeb-86cf1c65b4bc","html_url":"https://github.com/grezniczek/redcap_javascript_injector","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"purl":"pkg:github/grezniczek/redcap_javascript_injector","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grezniczek%2Fredcap_javascript_injector","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grezniczek%2Fredcap_javascript_injector/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grezniczek%2Fredcap_javascript_injector/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grezniczek%2Fredcap_javascript_injector/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grezniczek","download_url":"https://codeload.github.com/grezniczek/redcap_javascript_injector/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grezniczek%2Fredcap_javascript_injector/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30096798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-04T21:59:23.547Z","status":"ssl_error","status_checked_at":"2026-03-04T21:57:50.415Z","response_time":59,"last_error":"SSL_read: 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":["redcap","redcap-external-module","redcap-repo"],"created_at":"2026-03-04T22:32:43.208Z","updated_at":"2026-03-04T22:32:43.676Z","avatar_url":"https://github.com/grezniczek.png","language":"PHP","funding_links":["https://www.paypal.com/donate/?hosted_button_id=6VRC2JFRCBGRN"],"categories":[],"sub_categories":[],"readme":"# REDCap JavaScript Injector\n\n[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.15120311.svg)](https://doi.org/10.5281/zenodo.15120311)\n\nA REDCap External Module that allows injection of JavaScript on pages.\n\n## Requirements\n\n- REDCap with EM Framework v14 support.\n\n## Installation\n\n- Clone this repo into `\u003credcap-root\u003e/modules/redcap_javascript_injector_v\u003cversion-number\u003e`, or\n- Obtain this module from the Consortium [REDCap Repo](https://redcap.vumc.org/consortium/modules/index.php) via the Control Center.\n- Go to _Control Center \u003e Technical / Developer Tools \u003e External Modules_ and enable REDCap JavaScript Injector.\n\n### Upgrading from version 1.x\n\nConfiguration data from version 1 of this module will be automatically converted to the new configuration model used by version 2.\n\n**Warning**: Once upgraded, there is no way going back to the previous configuration! Thus, it is strongly advised to make a backup of the module settings in all projects using _JavaScript Injector_ before upgrading.\n\n## Project Configuration\n\nIn a project, go to _Applications \u003e External Modules_ and click the _Configure_ button for the REDCap JS Injector module.\n\nIn the configuration dialog, you can define JavaScript snippets for your project that are injected in _All project pages_ or limited to a choice of different project pages, including \n- _Project Home Page_,\n- _Project Setup Page_,\n- _Record Status Dashboard_,\n- _Add / Edit Records_,\n- _Record Home Page_, \n- _Data Entry Pages_,\n- _Surveys_,\n- _Reports_, and\n- _Project Dashboards_.\n\nFor data entry and survey pages, injection can be further limited by specifying one or more instruments.\n\nAdditionally, project injection pages can be controlled by adding parts of the URL to inclusion (_Enable_) and exclusion (_Disable_) list. When any inclusion items are found in the URL, a snippet is included. When any exclusion item matches, the injection will be rejected. Exclusion has priority over inclusion (and over any of the other settings). Add one item per line. When a line consists of multiple character sequences separated by spaces, all of them have to match, but the order or overlaps are not important.\nE.g., to match the _\"Create New Report\"_ and _\"Edit Existing Report\"_ pages, add this to the inclusion box: `DataExport/index.php addedit=1`. To target the _\"Create New Report\"_ specifically, you could add the term `create=1` to the inclusion box (on the same line), or alternatively add `report_id=` to the exclusion box.\n\nIf more than one snippet is injected on the same page, the injections occur in the order the snippets are defined in the configuration dialog.\n\n## System Configuration\n\nAdmins can set this module's project configurations to be accessible only to super users with the **Allow only super-users to configure this module in projects** option.\n\n**New since version 2:** Admins can define _global_ JavaScript injections and optionally limit their scope to certain pages.\n\n\u003e **NOTE:** Note that for any injections targeted at project contexts, these will only work if the module is enabled in the projects. To achieve this without exposing the module's project configuration too widely, it is recommended to turn on **Enable module on all projects by default** and **Hide this module from non-admins in the list of enabled modules on each project** (and then enable visibility in the projects where the module should be exposed). \n\nSnippets can be turned on/off for system/projects contexts with the **Enabled in system/project contexts** options. For both, system and project pages, the pages where injection occurs can then be set to include all such context pages or to be limited to a few selected pages.\n\nIn addition to the projects pages listed above, the following non-project pages can be targeted:\n- _Control Center_ (this will include any of the other listed options),\n- _To-Do List_,\n- _Language File Creator/Updater_,\n- _Browse Projects_,\n- _Create/Edit Single User_,\n- _Email Users_,\n- _Login Page_,\n- _Home_,\n- _My Projects_, \n- _New Project_, \n- _Help \u0026 FAQ_, \n- _Training Videos_, \n- _Send-It_, and\n- _Sponsor Dashboard_\n\nIf more than one snippet is injected on the same page, the injections occur in the order the snippets are defined in the configuration dialog.\n\n## JavascriptModuleObject and Dynamic Pages\n\nWhen injecting into dynamic pages, the effect of a JavaScript snippet may have to be re-applied after a re-render of a page (without reloading). This is often the case on survey pages and data entry forms with Multi-Language Management (MLM) enabled, as switching between languages redraws parts of the screen. To detect such changes, the EM Framework's _JavascriptModuleObject_ (JSMO) provides a convenient mechanism (`JSMO.afterRender()`), where a callback function can be regisered that will then be executed each time after REDCap has redrawn (parts of) the page. While `afterRender` will be mostly triggered by MLM, this mechanism is not dependent on MLM being active, and thus can be used on any page, with MLM turned on or off. Access to the JSMO in custom JavaScript snippets can now be obtained by enabling the **Add the JavascriptModuleObject** option (the concrete name of the JSMO is shown under this option). This option should be enabled for each JavaScript snippet that uses the JSMO (the module and _EM Framework_ will ensure that the JSMO is injected only once).\n\nThus, to have JavaScript snippet do something each time after a re-render of the page, inject code such as this:\n\n```JS\nExternalModules.DE.RUB.JSInjectorExternalModule.afterRender(function() {\n    console.log('Rendered'); // Replace with your code\n});\n```\n\n\n## Acknowledgments\n\nThe original version of this external module was basically just a modified version of the [REDCap CSS Injector](https://github.com/ctsit/redcap_css_injector) module. Version 2 is a major overhaul. \n\n## Changelog\n\nVersion | Description\n------- | ------------------\n2.3.1   | Fixed Repository link in README.\n2.3.0   | New feature: Add JS from a file in addition to entering it into directly into module config.\u003cbr\u003eNew options to direct injections.\n2.2.1   | Added support for new page: Project Setup Page.\n2.2.0   | Require EM Framework v14.\u003cbr\u003eAdded \"enable-every-page-hooks-on-login-form\" to config.json.\n2.1.1   | Minor code change to prevent a PHP strict mode warning.\n2.1.0   | Support for addition all system page: Home, My Projects, New Project, Help \u0026 FAQ, Training Videos, Send-It, Sponsor Dashboard.\u003cbr\u003eBumped framework version to 12.\n2.0.2   | Removed class constructor; PHP8-related fix.\n2.0.1   | Bugfix (broken form list limitation).\n2.0.0   | Major new feature: System and pan-project injections.\u003cbr\u003eRedesigned page limitation setup (old settings will be migrated automatically).\u003cbr\u003eDebug logging.\n1.1.4   | Added additional injection options.\n1.1.3   | Fix an issue where a (silent, but logged) exception would be thrown.\n1.1.2   | Add system setting for limiting project configuration access to super users only.\n1.1.1   | Fix the _All project pages_ behavior that was broken in version 1.1.0.\u003cbr\u003eDisable branching logic.\u003cbr\u003eAdd instructions for testing the module.\n1.1.0   | New feature: Inject JS on more project pages: _Project Home Page_, _Record Home Page_, _Add / Edit Records_, and _Record Status Dashboard_.\n1.0.0   | Initial release.\n\n## How to cite this work\n\nIf you use this external module for a project that generates a research output, please cite this software in addition to [citing REDCap](https://projectredcap.org/resources/citations/). You can do so using the APA referencing style as below:\n\n\u003e Rezniczek, G. A. (2025). REDCap JavaScript Injector [Computer software]. https://doi.org/10.5281/zenodo.15120311\n\nOr by adding this reference to your BibTeX database:\n\n```bibtex\n@software{Rezniczek_REDCap_JavaScript_Injector_2025,\n  author = {Rezniczek, Günther A.},\n  title = {{REDCap JavaScript Injector}},\n  version = {2.3.1},\n  year = {2025}\n  month = {5},\n  doi = {10.5281/zenodo.15120311},\n  url = {https://github.com/grezniczek/redcap_javascript_injector},\n}\n```\n\nThese instructions are also available in [GitHub](https://github.com/grezniczek/redcap_javascript_injector) under 'Cite This Repository'.\n\n## Support this work\n\nIf you find this software useful, you can [buy me a coffee or a beer](https://www.paypal.com/donate/?hosted_button_id=6VRC2JFRCBGRN). Your support is purely voluntary and helps me continue improving this project. Of course, you are not entitled to any special benefits—except my silent appreciation while enjoying the drink! 🍻☕  \n\nYou can use the link or the QR code below to make a donation via PayPal.\n\n![PayPal QR Code](/images/qr-paypal.png)\n\n_Please note that donations are purely voluntary and not tax-deductible._\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrezniczek%2Fredcap_javascript_injector","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrezniczek%2Fredcap_javascript_injector","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrezniczek%2Fredcap_javascript_injector/lists"}