I want to create chrome extension using simple html,css, JavaScript. which should block all frame ads on any website and replace with my ads which is created in simple html.
i try below code,
var enabled = true;
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if(enabled) {
console.log("blocking:", details.url);
chrome.tabs.executeScript(null, {file: "jquery.js"}, function() {
chrome.tabs.executeScript(null, {
file : content_script.js
});
});
//alert(newSong);
}
//$(details).closest('iframe').remove();
return {cancel: enabled };
},
{urls: blocked_domains},
//{urls: ["<all_urls>"]}, /* replace with list of blacklisted urls */
["blocking"]
);
and content_script.js
$(window).load(function() {
$('iframe').each(function(){
//$(this).contents().find('img').remove();
$('iframe').attr('src','https://www.w3schools.com/css/rock600x400.jpg');
});
});
also tried below code but none of work,
browser.tabs.onUpdated.addListener(function(tabId, changeInfo, tab) { //when current tab updated
updateLabel();
});
browser.tabs.onActivated.addListener(function(activeInfo) { //when tab shift
browser.tabs.get(activeInfo.tabId, function(tab){
updateLabel();
});
});
please check my code or suggest me simple code.