-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4748ad5
commit 1a31947
Showing
7 changed files
with
121 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>SEO Analysis Tool</title> | ||
<link rel="stylesheet" href="style.css"> | ||
</head> | ||
<body> | ||
<div class="container"> | ||
<h1>SEO Analyzer</h1> | ||
<input type="text" id="url-input" placeholder="Enter URL"> | ||
<button id="analyze-btn">Analyze</button> | ||
<div id="results"> | ||
<h2>Results:</h2> | ||
<p id="title-tag">Title Tag: <span></span></p> | ||
<p id="meta-description">Meta Description: <span></span></p> | ||
<p id="h1-tag">H1 Tag: <span></span></p> | ||
<p id="word-count">Word Count: <span></span></p> | ||
</div> | ||
</div> | ||
<script src="script.js"></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 |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"manifest_version": 3, | ||
"name": "SEO Analyzer", | ||
"version": "1.0", | ||
"description": "A tool to analyze the SEO of a webpage.", | ||
"permissions": [ | ||
"activeTab" | ||
], | ||
"action": { | ||
"default_popup": "index.html", | ||
"default_icon": { | ||
"16": "icon16.png", | ||
"48": "icon48.png", | ||
"128": "icon128.png" | ||
} | ||
}, | ||
"icons": { | ||
"16": "icon16.png", | ||
"48": "icon48.png", | ||
"128": "icon128.png" | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
document.getElementById('analyze-btn').addEventListener('click', analyzeSEO); | ||
|
||
async function analyzeSEO() { | ||
const url = document.getElementById('url-input').value; | ||
if (!url) { | ||
alert('Please enter a URL'); | ||
return; | ||
} | ||
|
||
try { | ||
const response = await fetch(`https://api.allorigins.win/get?url=${encodeURIComponent(url)}`); | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
} | ||
|
||
const rawResponse = await response.text(); | ||
console.log('Raw response:', rawResponse); | ||
|
||
const data = JSON.parse(rawResponse); | ||
|
||
const parser = new DOMParser(); | ||
const doc = parser.parseFromString(data.contents, 'text/html'); | ||
|
||
const title = doc.querySelector('title') ? doc.querySelector('title').innerText : 'No title found'; | ||
|
||
const metaDescription = doc.querySelector('meta[name="description"]') | ||
? doc.querySelector('meta[name="description"]').getAttribute('content') | ||
: 'No meta description found'; | ||
|
||
const h1 = doc.querySelector('h1') ? doc.querySelector('h1').innerText : 'No H1 tag found'; | ||
|
||
const wordCount = doc.body.innerText.split(/\s+/).filter(Boolean).length; | ||
|
||
document.querySelector('#title-tag span').innerText = title; | ||
document.querySelector('#meta-description span').innerText = metaDescription; | ||
document.querySelector('#h1-tag span').innerText = h1; | ||
document.querySelector('#word-count span').innerText = wordCount; | ||
|
||
} catch (error) { | ||
console.error('Error fetching or processing the URL:', error); | ||
alert('Failed to fetch the URL or process the content. Please check the console for more details.'); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
body { | ||
font-family: Arial, sans-serif; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
margin: 0; | ||
background-color: #f0f0f0; | ||
} | ||
|
||
.container { | ||
text-align: center; | ||
background: #fff; | ||
padding: 20px; | ||
border-radius: 10px; | ||
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1); | ||
} | ||
|
||
input, button { | ||
padding: 10px; | ||
margin: 5px; | ||
font-size: 16px; | ||
} | ||
|
||
#results { | ||
margin-top: 20px; | ||
text-align: left; | ||
} | ||
|
||
#results h2 { | ||
margin-bottom: 10px; | ||
} |