Невозможно загрузить файл content.js 'chrome расширениеHtml

Программисты Html
Anonymous
Невозможно загрузить файл content.js 'chrome расширение

Сообщение Anonymous »

У меня есть форма в opup.html, поэтому пользователь сможет использовать функцию расширения только после регистрации. Однако я получаю следующую ошибку < /p>


Unchecked runtime.lasterror при запуске Tabs.executcript: не удалось
to load file: "Content.js".
at getPadeTails < /p>
< /blockquote>

Это может быть причиной, функция входа не может быть реализована, потому что я утешал в этой функции, но она не отображается. < /p>

Вот код < /p>

popup.html < /strong> < /p>










Login








< /code>

popup.js


// This callback function is called when the content script has been
// injected and returned its results
function onPageDetailsReceived(pageDetails) {
document.getElementById('email').value = pageDetails.email;
document.getElementById('password').value = pageDetails.password;
}

// Global reference to the status display SPAN
var statusDisplay = null;

// POST the data to the server using XMLHttpRequest
function Login() {
// Cancel the form submit
event.preventDefault();

// The URL to POST our data to
var postUrl = 'http://127.0.0.1:3008/users/sign_in';

// Prepare the data to be POSTed by URLEncoding each field's contents
var email = document.getElementById('email');
var password = document.getElementById('password');
var body = {
email: email,
password: password
}
const headers = new Headers();
headers.append('Content-Type', 'application/json');
console.log('apiurl', postUrl, headers, body)
fetch(postUrl, {
method: 'POST',
headers:headers,
data: data
})
.then(function(response){
console.log('respnse ------>', response)
return response.json()
})
.then(function(data){
console.log('data ------->', data)
})
.catch(function(err){
console.log('err ---->', err)
})
}

// When the popup HTML has loaded
window.addEventListener('load', function(evt) {
// Cache a reference to the status display SPAN
statusDisplay = document.getElementById('status-display');
console.log('document', document.getElementById('login'))
document.getElementById('login')
.addEventListener('submit', Login);
// Get the event page
chrome.runtime.getBackgroundPage(function(eventPage) {
// Call the getPageInfo function in the event page, passing in
// our onPageDetailsReceived function as the callback. This
// injects content.js into the current tab's HTML
eventPage.getPageDetails(onPageDetailsReceived);
});
});
< /code>

eventpage.js

// This function is called onload in the popup code
function getPageDetails(callback) {

// Inject the content script into the current page
chrome.tabs.executeScript(null, { file: 'content.js' }); // could not find it says
// When a message is received from the content script
chrome.runtime.onMessage.addListener(function(message) {
// Call the callback function i.e onPageDetailsReceived in our case
callback(message);
});
};
< /code>

Примечание: popup.js, event -page.js, founal.js All находится в одном и том же месте < /p>

Мой манифестный файл выглядит как следующий < /p>

"permissions": [
"activeTab",
"storage",
"contextMenus",
"http://*/*",
"https://*/*"
],
"options_page": "html/popup.html",
"background": {
"scripts": ["js/eventPage.js", "js/background.js"],
"persistent": false
},
"content_scripts": [
{
"matches" : [
"http://*/*", "https://*/*"
],
"js" : [
"js/content.js"
]
}
],


Подробнее здесь: https://stackoverflow.com/questions/502 ... -extension

Вернуться в «Html»