-
Notifications
You must be signed in to change notification settings - Fork 1
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
Showing
8 changed files
with
192 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,23 @@ | ||
let linksDictionary = {}; | ||
|
||
function parseAndLogLinks() { | ||
const linkElements = document.querySelectorAll('a[class="tilk"]'); | ||
linkElements.forEach(linkElement => { | ||
const link = linkElement.getAttribute('href'); | ||
if (!(link in linksDictionary)) { | ||
linksDictionary[link] = true; | ||
console.log(link); | ||
} | ||
}); | ||
|
||
browser.storage.local.set({ links: Object.keys(linksDictionary) }, function() { | ||
console.log('Links saved to storage'); | ||
}); | ||
} | ||
|
||
const observer = new MutationObserver(parseAndLogLinks); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
|
||
window.addEventListener('scroll', () => { | ||
browser.runtime.sendMessage({ action: 'updateLinksCount' }); | ||
}); |
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,23 @@ | ||
let linksDictionary = {}; | ||
|
||
function parseAndLogLinks() { | ||
const linkElements = document.querySelectorAll('a[class="eVNpHGjtxRBq_gLOfGDr LQNqh2U1kzYxREs65IJu"]'); | ||
linkElements.forEach(linkElement => { | ||
const link = linkElement.getAttribute('href'); | ||
if (!(link in linksDictionary)) { | ||
linksDictionary[link] = true; | ||
console.log(link); | ||
} | ||
}); | ||
|
||
browser.storage.local.set({ links: Object.keys(linksDictionary) }, function() { | ||
console.log('Links saved to storage'); | ||
}); | ||
} | ||
|
||
const observer = new MutationObserver(parseAndLogLinks); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
|
||
window.addEventListener('scroll', () => { | ||
browser.runtime.sendMessage({ action: 'updateLinksCount' }); | ||
}); |
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,23 @@ | ||
let linksDictionary = {}; | ||
|
||
function parseAndLogLinks() { | ||
const linkElements = document.querySelectorAll('a[jsname="UWckNb"]'); | ||
linkElements.forEach(linkElement => { | ||
const link = linkElement.getAttribute('href'); | ||
if (!(link in linksDictionary)) { | ||
linksDictionary[link] = true; | ||
console.log(link); | ||
} | ||
}); | ||
|
||
browser.storage.local.set({ links: Object.keys(linksDictionary) }, function() { | ||
console.log('Links saved to storage'); | ||
}); | ||
} | ||
|
||
const observer = new MutationObserver(parseAndLogLinks); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
|
||
window.addEventListener('scroll', () => { | ||
browser.runtime.sendMessage({ action: 'updateLinksCount' }); | ||
}); |
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,31 @@ | ||
{ | ||
"manifest_version": 2, | ||
"name": "Search Links Scraper", | ||
"version": "1.0", | ||
"permissions": ["activeTab", "tabs", "storage", "downloads"], | ||
"browser_action": { | ||
"default_icon": "icons/icon128.png", | ||
"default_popup": "popup.html" | ||
}, | ||
"icons": { | ||
"128": "icons/icon128.png" | ||
}, | ||
"content_scripts": [ | ||
{ | ||
"matches": ["*://www.google.com/*"], | ||
"js": ["google.js"] | ||
}, | ||
{ | ||
"matches": ["*://yandex.ru/*"], | ||
"js": ["yandex.js"] | ||
}, | ||
{ | ||
"matches": ["*://www.bing.com/*"], | ||
"js": ["bing.js"] | ||
}, | ||
{ | ||
"matches": ["*://duckduckgo.com/*"], | ||
"js": ["duck.js"] | ||
} | ||
] | ||
} |
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,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Google Link Scraper</title> | ||
<style> | ||
body { | ||
width: 300px; | ||
padding: 10px; | ||
font-family: Arial, sans-serif; | ||
} | ||
button { | ||
width: 100%; | ||
padding: 8px 0; | ||
background-color: #4CAF50; | ||
color: white; | ||
border: none; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
margin-bottom: 10px; | ||
} | ||
</style> | ||
</head> | ||
<body> | ||
<h2>Search Links Scraper</h2> | ||
<p>Total links: <span id="totalLinks">0</span></p> | ||
<button id="saveLinks">Save Links From Search</button> | ||
<script src="popup.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,39 @@ | ||
document.addEventListener('DOMContentLoaded', () => { | ||
const saveLinksButton = document.getElementById('saveLinks'); | ||
const totalLinksSpan = document.getElementById('totalLinks'); | ||
|
||
// Function to update total links count | ||
function updateTotalLinksCount() { | ||
browser.storage.local.get('links', (data) => { | ||
const links = data.links || []; | ||
totalLinksSpan.textContent = links.length; | ||
}); | ||
} | ||
|
||
// Update total links count when popup opens | ||
updateTotalLinksCount(); | ||
|
||
// Save links button functionality | ||
saveLinksButton.addEventListener('click', () => { | ||
browser.storage.local.get('links', (data) => { | ||
const links = data.links || []; | ||
const file = new Blob([links.join('\n')], { type: 'text/plain' }); | ||
const url = URL.createObjectURL(file); | ||
const link = document.createElement('a'); | ||
link.href = url; | ||
link.download = 'links.txt'; | ||
link.click(); | ||
URL.revokeObjectURL(url); | ||
}); | ||
}); | ||
|
||
// Update total links count when scrolling the page | ||
browser.tabs.executeScript({ code: 'window.addEventListener("scroll", () => { browser.runtime.sendMessage({ action: "updateLinksCount" }); });' }); | ||
|
||
// Listen for messages from content script to update total links count | ||
browser.runtime.onMessage.addListener((message) => { | ||
if (message.action === 'updateLinksCount') { | ||
updateTotalLinksCount(); | ||
} | ||
}); | ||
}); |
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,23 @@ | ||
let linksDictionary = {}; | ||
|
||
function parseAndLogLinks() { | ||
const linkElements = document.querySelectorAll('a[class="Link Link_theme_normal OrganicTitle-Link organic__url link"]'); | ||
linkElements.forEach(linkElement => { | ||
const link = linkElement.getAttribute('href'); | ||
if (!(link in linksDictionary)) { | ||
linksDictionary[link] = true; | ||
console.log(link); | ||
} | ||
}); | ||
|
||
browser.storage.local.set({ links: Object.keys(linksDictionary) }, function() { | ||
console.log('Links saved to storage'); | ||
}); | ||
} | ||
|
||
const observer = new MutationObserver(parseAndLogLinks); | ||
observer.observe(document.body, { childList: true, subtree: true }); | ||
|
||
window.addEventListener('scroll', () => { | ||
browser.runtime.sendMessage({ action: 'updateLinksCount' }); | ||
}); |