URL-адрес, который тестируется с расширением chrome, должен быть сохранен в текстовом файле. Например, если stackoverflow.com тестируется на расширение, этот URL должен быть сохранен в текстовом файле. Я приложил снимок экрана с расширением, в котором проверяемый URL должен быть сохранен в текстовом файле. Для этого какой код я должен добавить?
Это json файл
{
"manifest_version": 2,
"name": "Phishing Website Detector",
"description": "This extension warns you about phishing websites",
"version": "1.0",
"browser_action":
{
"default_icon": "icon.png",
"default_popup": "popup.html"
},
"content_security_policy": "script-src 'self' https://ajax.googleapis.com; object-src 'self'",
"permissions":
[
"activeTab",
"tabs",
"storage",
"https://ajax.googleapis.com",
"tabs",
"<all_urls>"
]
}
И это js файл, который я использовал
function transfer()
{
var tablink;
chrome.tabs.getSelected(null,function(tab)
{
tablink = tab.url;
$("#p1").text("The URL being tested is - "+tablink);
var xhr=new XMLHttpRequest();
params="url="+tablink;
// alert(params);
var markup = "url="+tablink+"&html="+document.documentElement.innerHTML;
xhr.open("POST","http://localhost/Malicious-Web-Content-Detection-Using-Machine-Learning/clientServer.php",false);
xhr.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhr.send(markup);
// Uncomment this line if you see some error on the extension to see the full error message for debugging.
// alert(xhr.responseText);
$("#div1").text(xhr.responseText);
return xhr.responseText;
});
}
$(document).ready(function()
{
$("button").click(function()
{
var val = transfer();
});
});
chrome.tabs.getSelected(null,function(tab)
{
var tablink = tab.url;
$("#p1").text("The URL being tested is - "+tablink);
});
Скриншот расширения