mirror of
https://github.com/momenbasel/keyFinder.git
synced 2026-09-21 00:40:48 +02:00
first commit
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||
if (request.method == "getStatus")
|
||||
sendResponse({status: localStorage});
|
||||
else
|
||||
sendResponse({});
|
||||
});
|
||||
|
||||
|
||||
|
||||
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
|
||||
if (request.getter)
|
||||
console.log(request.getter);
|
||||
localStorage.setItem(request.getter,request.getter);
|
||||
});
|
||||
Vendored
+7
File diff suppressed because one or more lines are too long
@@ -0,0 +1,59 @@
|
||||
|
||||
console.log("keyFinder🔑 is working!");
|
||||
|
||||
|
||||
|
||||
//custom searches
|
||||
|
||||
let js = document.getElementsByTagName('script');
|
||||
|
||||
|
||||
|
||||
chrome.runtime.sendMessage({method: "getStatus"}, function(response) {
|
||||
|
||||
var savedSearch = response.status;
|
||||
|
||||
for (var key in savedSearch) {
|
||||
|
||||
if (savedSearch.hasOwnProperty(key)) {
|
||||
|
||||
for(src in js){
|
||||
|
||||
var url = js[src].src;
|
||||
let regex = new RegExp(key,'i');
|
||||
|
||||
try {
|
||||
|
||||
if(url.search(regex) !== -1) {
|
||||
chrome.runtime.sendMessage({getter: url}, function(response) {
|
||||
});
|
||||
console.log(`KeyFinder: a potential API key found: ${url} it matched your search ${key}`);
|
||||
}
|
||||
|
||||
} catch(err) {
|
||||
//do nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// for GoogleMaps API key
|
||||
for (src in js) {
|
||||
let url = js[src].src;
|
||||
try {
|
||||
if(url.search(/key/i) !== -1) {
|
||||
console.log(`KeyFinder: a potential API key found: ${url}`)
|
||||
|
||||
//saving the results
|
||||
chrome.runtime.sendMessage({getter: url}, function(response) {
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
//console.log(err)
|
||||
}
|
||||
}
|
||||
Vendored
+2
File diff suppressed because one or more lines are too long
Vendored
+5
File diff suppressed because one or more lines are too long
+48
@@ -0,0 +1,48 @@
|
||||
var save = document.getElementById('save');
|
||||
|
||||
|
||||
|
||||
save.onclick = function() {
|
||||
|
||||
var keyword = document.getElementById("keyword").value;
|
||||
|
||||
|
||||
if(keyword == "key") {
|
||||
alert("already exist!");
|
||||
|
||||
}
|
||||
if(keyword === ""){
|
||||
alert("cannot be empty");
|
||||
}
|
||||
|
||||
if(keyword == localStorage.getItem(keyword)){
|
||||
alert("you can't add the same word twice!")
|
||||
}
|
||||
else
|
||||
{
|
||||
keyword.trim();
|
||||
//setting key value to keyword for easy lopping
|
||||
localStorage.setItem(keyword,keyword);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var i;
|
||||
for(i=0; i < localStorage.length; i++) {
|
||||
//regex to filter keywords from localStorage and showing URLS
|
||||
if(!/(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(localStorage.key(i))){
|
||||
if(localStorage.key(i) !== 'undefined')
|
||||
{
|
||||
$('body').append(`<li>${localStorage.key(i)}<button value=${localStorage.key(i)} class="btn"><i class="fa fa-trash"></i></button></li>`)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$('.btn').click(function() {
|
||||
var selectedItem = $(this).val();
|
||||
localStorage.removeItem(selectedItem);
|
||||
location.reload();
|
||||
alert(`${selectedItem} removed`);
|
||||
})
|
||||
@@ -0,0 +1,87 @@
|
||||
//Searching localStorage for URL
|
||||
var i;
|
||||
for(i=0; i < localStorage.length; i++) {
|
||||
//regex to filter keywords from localStorage and showing URLS
|
||||
if(/(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(localStorage.key(i))){
|
||||
$('.table').append(`
|
||||
<tr>
|
||||
<td scope="row"></td>
|
||||
<td>${extractHostname(localStorage.key(i))}</td>
|
||||
<td> <a href='${localStorage.key(i)}'>${localStorage.key(i)}</a> <button value=${localStorage.key(i)} class="btn"><i class="fa fa-trash"></i></button> </td>
|
||||
<td>${searchKeywordOnURL(localStorage.key(i))}</td>
|
||||
<tr>
|
||||
<style>
|
||||
|
||||
`)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function searchKeywordOnURL(key) {
|
||||
let i;
|
||||
var keyword;
|
||||
for(i=0; i < localStorage.length; i++) {
|
||||
//regex to filter keywords from localStorage and showing URLS
|
||||
if(!/(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/i.test(localStorage.key(i))){
|
||||
if(key.indexOf(localStorage.key(i)) !== -1) {
|
||||
return localStorage.key(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//numbering results && self-inovking the function
|
||||
(function(cl){
|
||||
var table = document.querySelector('table.' + cl)
|
||||
var trs = table.querySelectorAll('tr')
|
||||
var counter = 1
|
||||
|
||||
Array.prototype.forEach.call(trs, function(x,i){
|
||||
var firstChild = x.children[0]
|
||||
if (firstChild.tagName === 'TD') {
|
||||
var cell = document.createElement('td')
|
||||
cell.textContent = counter ++
|
||||
x.insertBefore(cell,firstChild)
|
||||
} else {
|
||||
firstChild.setAttribute('colspan',2)
|
||||
}
|
||||
})
|
||||
})("table");
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//delete
|
||||
$('.btn').click(function() {
|
||||
var selectedItem = $(this).val();
|
||||
localStorage.removeItem(selectedItem);
|
||||
location.reload();
|
||||
alert(`${selectedItem} removed`);
|
||||
})
|
||||
|
||||
//extract domain name from URL
|
||||
function extractHostname(url) {
|
||||
var hostname;
|
||||
//find & remove protocol (http, ftp, etc.) and get hostname
|
||||
|
||||
if (url.indexOf("//") > -1) {
|
||||
hostname = url.split('/')[2];
|
||||
}
|
||||
else {
|
||||
hostname = url.split('/')[0];
|
||||
}
|
||||
|
||||
//find & remove port number
|
||||
hostname = hostname.split(':')[0];
|
||||
//find & remove "?"
|
||||
hostname = hostname.split('?')[0];
|
||||
|
||||
return hostname;
|
||||
}
|
||||
Reference in New Issue
Block a user