
Company News
/Security News
Socket Selected for OpenAI's Cybersecurity Grant Program
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.
@hal313/html-amend
Advanced tools
Amends HTML by inserting attributes into elements, or elements into the DOM.
Amends HTML by inserting attributes into elements, or elements into the DOM.
No HTML parsing! This is good because it is quick and easy... but also limited. Currently, only the first occurrence of an element is supported. It should be fairly trivial to add advanced locators.
| Package | html-amend |
| Description | Amends HTML by inserting attributes into elements, or elements into the DOM. |
| Node Version | >= 6 |
$ npm install html-amend --save-dev
/**
* Replaces content specified by a regular expression with specified content.
*
* @param {String|Function} input the input to replace
* @param {String|RegExp|Function} regEx the regular expression (or string) to replace within the input
* @param {String|Function} [content] the content to replace
* @return {String} a String which has the first occurrence of the regular expression within input replaced with the content
* @throws {String} when input or regex are not defined
*/
function replaceWith(input, regex, content);
/**
* Inserts content into the input string after the first occurrence of the element has been opened.
*
* @param {String|Function} input the input to replace
* @param {String|Function} element the element to insert after
* @param {String|Function} [content] the content to insert within the input string
* @return {String} a String which has the content added after the first occurrence of the element open tag within the input string
* @throws {String} when input or element are not defined
*/
function afterElementOpen(input, element, content);
/**
* Inserts content into the input string before the first occurrence of the element close tag.
*
* @param {String|Function} input the input to replace
* @param {String|Function} element the element to insert before close
* @param {String|Function} content the content to replace within the input string
* @return {String} a String which has the content added before the first occurrence of the element close tag within the input string
* @throws {String} when input or element are not defined
*/
function beforeElementClose(input, element, content)
/**
* Inserts an HTML comment into the input string after the first occurrence of the element close tag.
*
* @param {String|Function} input the input to replace
* @param {String|Function} element the element to add the comment after
* @param {String|Function} [content] the comment to add.
* @return {String} a String which has the comment added after the first occurrence of the element close tag within the input string
* @throws {String} when input or element are not defined
*/
function insertComment(input, element, comment)
/**
* Inserts an attribute into the input string within the first occurrence of the element open tag.
*
* @param {String|Function} input the input string
* @param {String|Function} element the element tag to modify
* @param {String|Function} attributeName the attribute name to add
* @param {String|Function} [attributeValue] the attribute value to add
* @return {String} a String which has the attribute added into the first occurrence of the element open tag
* @throws {String} when input, element or attributeName are not defined
*/
function insertAttribute(input, element, attributeName, attributeValue);
npm install
npm run build
Tests expect to be run against an distribution, so be sure to build before running tests.
npm run test
To re-run tests during development:
npm run test:watch
This is a basic script which can be used to build and deploy (to NPM) the project.
export VERSION=<NEXT VERSION>
git checkout -b release/$VERSION
npm version --no-git-tag-version patch
npm run build
npm run test
git add package*
git commit -m 'Version bump'
npx auto-changelog -p
git add CHANGELOG.md
git commit -m 'Updated changelog'
git checkout master
git merge --no-ff release/$VERSION
git tag -a -m 'Tagged for release' $VERSION
git branch -d release/$VERSION
git checkout develop
git merge --no-ff master
git push --all && git push --tags
FAQs
Amends HTML by inserting attributes into elements, or elements into the DOM.
The npm package @hal313/html-amend receives a total of 5 weekly downloads. As such, @hal313/html-amend popularity was classified as not popular.
We found that @hal313/html-amend demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
/Security News
Socket is an initial recipient of OpenAI's Cybersecurity Grant Program, which commits $10M in API credits to defenders securing open source software.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.