-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding of audio captcha and captcha history that will help to genarate new captcha's in captcha generator project. #217
- Loading branch information
1 parent
742aa5f
commit 6f05930
Showing
3 changed files
with
135 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,91 @@ | ||
<!-- captcha generator in js --> | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Captcha Generator</title> | ||
<link rel="stylesheet" href="src/style.css" /> | ||
<link rel="stylesheet" href="src/style.css"> | ||
<!-- Fontawesome CDN Link --> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css" /> | ||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.2.1/css/all.min.css"> | ||
<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<header>Captcha Generator</header> | ||
<div class="input_field captch_box"> | ||
<input type="text" value="" disabled /> | ||
<button class="refresh_button"> | ||
<i class="fa-solid fa-rotate-right"></i> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<header>Captcha Generator</header> | ||
<div class="input_field captch_box"> | ||
<input id="captchaOutput" type="text" value="" disabled /> | ||
<button class="refresh_button" onclick="generateCaptcha()"> | ||
<i class="fa-solid fa-rotate-right"></i> | ||
</button> | ||
</div> | ||
<div class="input_field captch_input"> | ||
<input type="text" placeholder="Enter captcha" /> | ||
</div> | ||
<div class="message">Entered captcha is correct</div> | ||
<div class="input_field button disabled"> | ||
<button>Submit Captcha</button> | ||
</div> | ||
</div> | ||
<div class="input_field captch_input"> | ||
<input id="captchaInput" type="text" placeholder="Enter captcha" /> | ||
</div> | ||
<div id="message" class="message">Entered captcha is correct</div> | ||
<div class="input_field button disabled"> | ||
<button onclick="checkCaptcha()">Submit Captcha</button> | ||
</div> | ||
<div class="captcha-history"> | ||
<h2>Captcha History</h2> | ||
<ul id="captchaHistoryList"></ul> | ||
</div> | ||
<div class="audio-captcha"> | ||
<button onclick="playAudioCaptcha()">Play Audio Captcha</button> | ||
<audio id="audioCaptcha" controls style="display: none;"> | ||
<source src="audio/captcha.mp3" type="audio/mpeg"> | ||
Your browser does not support the audio element. | ||
</audio> | ||
</div> | ||
</div> | ||
|
||
<script src="scripts/script.js"></script> | ||
<script> | ||
var captchaHistory = []; | ||
|
||
function generateCaptcha() { | ||
// Generate a random captcha | ||
var captcha = Math.random().toString(36).slice(2, 8).toUpperCase(); | ||
document.getElementById("captchaOutput").value = captcha; | ||
captchaHistory.unshift(captcha); // Add to history | ||
} | ||
|
||
function checkCaptcha() { | ||
var inputCaptcha = document.getElementById("captchaInput").value.toUpperCase(); | ||
var generatedCaptcha = captchaHistory[0]; | ||
if (inputCaptcha === generatedCaptcha) { | ||
// Correct captcha | ||
document.getElementById("message").textContent = "Entered captcha is correct"; | ||
// Remove from history | ||
captchaHistory.shift(); | ||
// Clear input field | ||
document.getElementById("captchaInput").value = ""; | ||
// Regenerate captcha | ||
generateCaptcha(); | ||
} else { | ||
// Incorrect captcha | ||
document.getElementById("message").textContent = "Entered captcha is incorrect"; | ||
} | ||
updateCaptchaHistory(); | ||
} | ||
|
||
function updateCaptchaHistory() { | ||
var list = document.getElementById("captchaHistoryList"); | ||
list.innerHTML = ""; | ||
for (var i = 0; i < captchaHistory.length; i++) { | ||
var listItem = document.createElement("li"); | ||
listItem.textContent = captchaHistory[i]; | ||
list.appendChild(listItem); | ||
} | ||
} | ||
|
||
function playAudioCaptcha() { | ||
var audio = document.getElementById("audioCaptcha"); | ||
audio.play(); | ||
} | ||
|
||
<script src="scripts/script.js"></script> | ||
</body> | ||
</html> | ||
// Generate initial captcha on page load | ||
generateCaptcha(); | ||
</script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,26 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "Captcha Validation Extension JS", | ||
"version": "1.0", | ||
"description": "Simple Captcha validation extension built in pure HTML CSS JS...", | ||
"permissions": [ | ||
"storage" | ||
], | ||
"action": { | ||
"default_popup": "index.html" | ||
"manifest_version": 3, | ||
"name": "Captcha Validation Extension JS", | ||
"version": "1.0", | ||
"description": "Simple Captcha validation extension built in pure HTML CSS JS...", | ||
"permissions": [ | ||
"activeTab", | ||
"storage" | ||
], | ||
"host_permissions": [ | ||
"<all_urls>" | ||
], | ||
"action": { | ||
"default_popup": "index.html" | ||
}, | ||
"web_accessible_resources": [ | ||
{ | ||
"resources": ["index.html"], | ||
"matches": ["<all_urls>"] | ||
}, | ||
"web_accessible_resources": [ | ||
{ | ||
"resources": ["index.html"], | ||
"matches": ["<all_urls>"] | ||
} | ||
] | ||
} | ||
|
||
{ | ||
"resources": ["scripts/*", "src/*", "audio/*"], | ||
"matches": ["<all_urls>"] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters