I'm trying to develop a google chrome extension which can block specific URL. For this with the help of google I've made following code, but the code is not work perfectly.
The code :
manifest.json
{
"manifest_version": 2,
"name": "Zitu-LinkBlocker",
"description": "A link blocker extension!",
"permissions": [
"tabs"
],
"version": "1.0",
"icons": {
"128": "icon128.png",
"48": "icon48.png",
"16": "icon16.png"
},
"browser_action": {
"default_icon": "icon16.png",
"default_popup": "popup.html"
}
}
popup.js
$(document).ready(function() {
chrome.tabs.query(null, function (tab) {
var link = document.createElement('a');
link.href = tab.url;
$('#host').html("Host : "+link.hostname);
})
});
popup.html
<!doctype html>
<html>
<head>
<title>Getting Started Extension's Popup</title>
<style>
body {
min-width: 357px;
overflow-x: hidden;
}
</style>
<script src="jquery-3.5.1.min.js"></script>
<script src="popup.js"></script>
</head>
<body>
Yo Man
<div id="host"></div>
</body>
</html>