diff --git a/SEO Analysis/icon128.png b/SEO Analysis/icon128.png new file mode 100644 index 00000000..ce927fbd Binary files /dev/null and b/SEO Analysis/icon128.png differ diff --git a/SEO Analysis/icon16.png b/SEO Analysis/icon16.png new file mode 100644 index 00000000..ddfe23aa Binary files /dev/null and b/SEO Analysis/icon16.png differ diff --git a/SEO Analysis/icon48.png b/SEO Analysis/icon48.png new file mode 100644 index 00000000..97a5448d Binary files /dev/null and b/SEO Analysis/icon48.png differ diff --git a/SEO Analysis/index.html b/SEO Analysis/index.html new file mode 100644 index 00000000..cd053474 --- /dev/null +++ b/SEO Analysis/index.html @@ -0,0 +1,24 @@ + + + + + + SEO Analysis Tool + + + +
+

SEO Analyzer

+ + +
+

Results:

+

Title Tag:

+

Meta Description:

+

H1 Tag:

+

Word Count:

+
+
+ + + diff --git a/SEO Analysis/manifest.json b/SEO Analysis/manifest.json new file mode 100644 index 00000000..4b06b0b9 --- /dev/null +++ b/SEO Analysis/manifest.json @@ -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" + } +} diff --git a/SEO Analysis/script.js b/SEO Analysis/script.js new file mode 100644 index 00000000..1c48b28d --- /dev/null +++ b/SEO Analysis/script.js @@ -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.'); + } +} diff --git a/SEO Analysis/style.css b/SEO Analysis/style.css new file mode 100644 index 00000000..704df117 --- /dev/null +++ b/SEO Analysis/style.css @@ -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; +}