Created
March 9, 2020 19:07
-
-
Save pakoy3k/a711e37c57083c01d5f36c90f73fc203 to your computer and use it in GitHub Desktop.
Demo de una Extensión para Chrome, grabar todo en un folder y agregar extensión en modo Dev
This file contains hidden or 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
{ | |
"manifest_version": 2, | |
"name": "Borg Analyzer Plugin", | |
"description": "This extension will analyze a page", | |
"version": "0.5", | |
"browser_action": { | |
"default_icon": "icon.png", | |
"default_popup": "popup.html" | |
}, | |
"permissions": [ | |
"tabs","activeTab","storage","declarativeContent" | |
] | |
} |
This file contains hidden or 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
<!doctype html> | |
<html> | |
<head> | |
<title>Borg Analyzer</title> | |
<script src="popup.js"></script> | |
</head> | |
<body> | |
<h1>Borg Analyzer</h1> | |
<button id="checkPage">Add this page</button> | |
</body> | |
</html> |
This file contains hidden or 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
document.addEventListener('DOMContentLoaded', function() { | |
var checkPageButton = document.getElementById('checkPage'); | |
function getData(){ | |
chrome.tabs.getSelected(null, function(tab) { | |
d = document; | |
aData = ""; | |
var j = document.all.length; | |
var links = document.getElementsByTagName("title"); | |
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ | |
aData = tabs[0].url; | |
wait(1000); | |
}); | |
}); | |
return aData; | |
}//getData | |
checkPageButton.addEventListener('click', function() { | |
// Create a request variable and assign a new XMLHttpRequest object to it. | |
var request = new XMLHttpRequest() | |
var urlAdd; | |
chrome.tabs.getSelected(null, function(tab) { | |
d = document; | |
aData = ""; | |
var j = document.all.length; | |
var links = document.getElementsByTagName("title"); | |
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){ | |
urlAdd = tabs[0].url; | |
request.open('POST', 'http://127.0.0.1:5000?url='+urlAdd, true); | |
request.send(); | |
}); | |
}); | |
// Open a new connection, using the GET request on the URL endpoint | |
}, false); | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment