K
To hand over thelet propt, bg.js- I only need every morning... // любой файл.js расширения:
let propt = 'text';
chrome.runtime.sendMessage({message: 'propt', value: propt});
// background.js
chrome.runtime.onMessage.addListener((r, sender, sR)=>{
console.log(r.message, r.value);
if(r.message === 'propt'){
// код
sR(true);
}
});
From any scruple of expansion, piled, to an active contribution:// любой файл.js расширения (popup.js):
let propt = 'text';
chrome.tabs.query({active: true}, ([tab])=>{
chrome.runtime.sendMessage(tab.id, {message: 'heyActiveTab', value: propt});
});
// content_scripts.js на активной вкладке
chrome.runtime.onMessage.addListener((r, sender, sR)=>{
console.log(r.message, r.value);
if(r.message === 'heyActiveTab'){
// code here
alert(r.value);
sR(true);
}
});
Some observations and read: https://learn.javascript.ru/structure and http://htmlbook.ru/samhtml/struktura-html-koda (structure) https://learn.javascript.ru/variables , about the pilgrims.exte https://developer.chrome.com/extensions/overview Yes, indeed. https://developer.chrome.com/extensions/getstarted https://habr.com/ru/post/305900/ If there's 18+ already, more like es6Don't forget why the file structure... IWait for the local file. I don't think I need a line.Cleaning function $('#ti_num').val('');, btw jq, the selter is going to give 1 element forever, so it's useless.