Back to project
JavaScript

Interaction and Simulation

This part handles the payload buttons, updates the demo output, and shows the warning popup when a payload looks dangerous.

function looksLikeXss(value) {
  return /<script|onerror|onload|javascript:/i.test(value);
}

function showXssAlert(payload) {
  alertBox.textContent = payload;
  overlay.classList.add('show');
}
document.querySelectorAll('.xss-chip').forEach((button) => {
  button.addEventListener('click', () => applyChipValue(button));
});