├── README.md ├── background.js ├── content_script.js ├── images ├── eye_closed.png └── eye_open.png ├── manifest.json ├── popup.html └── popup.js /README.md: -------------------------------------------------------------------------------- 1 | # HTML Comment Finder 2 | Browser extension to find HTML comments on pages. Useful if you visit obscure sites and don't want to miss any secrets. 3 | Will become red and show number if there are comments and green if there's none. 4 | 5 | [Download on Chrome Web Store](https://chrome.google.com/webstore/detail/html-comments-finder/opijbipenamgfcnhfpklbamhaanhhpda) 6 | 7 | ![screenshot](https://lune.dimden.dev/14a7b0587d.png) -------------------------------------------------------------------------------- /background.js: -------------------------------------------------------------------------------- 1 | chrome.runtime.onMessage.addListener(async (request, sender, sendResponse) => { 2 | if(request.action === "set") { 3 | chrome.action.setBadgeText({ 4 | text: request.comments.length > 0 ? request.comments.length.toString() : '', 5 | tabId: sender.tab.id 6 | }); 7 | chrome.action.setIcon({ 8 | path: request.comments.length > 0 ? 'images/eye_open.png' : 'images/eye_closed.png', 9 | tabId: sender.tab.id 10 | }); 11 | } 12 | }); 13 | 14 | -------------------------------------------------------------------------------- /content_script.js: -------------------------------------------------------------------------------- 1 | function filterNone() { 2 | return NodeFilter.FILTER_ACCEPT; 3 | } 4 | 5 | function getAllComments(rootElem) { 6 | let comments = []; 7 | let iterator = document.createNodeIterator(rootElem, NodeFilter.SHOW_COMMENT, filterNone, false); 8 | let curNode; 9 | while (curNode = iterator.nextNode()) { 10 | comments.push(curNode.nodeValue); 11 | } 12 | return comments; 13 | } 14 | 15 | setTimeout(() => { 16 | chrome.runtime.sendMessage({action: "set", comments: getAllComments(document).filter(c => c.trim().length > 0)}); 17 | }, 500); 18 | 19 | chrome.runtime.onMessage.addListener((request, sender, sendResponse) => { 20 | if(request.action === "get") { 21 | sendResponse(getAllComments(document).filter(c => c.trim().length > 0)); 22 | } 23 | }); -------------------------------------------------------------------------------- /images/eye_closed.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimdenGD/html-comment-finder/94e0574f4bc03672d1f8b64abb022f19ae2c1080/images/eye_closed.png -------------------------------------------------------------------------------- /images/eye_open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/dimdenGD/html-comment-finder/94e0574f4bc03672d1f8b64abb022f19ae2c1080/images/eye_open.png -------------------------------------------------------------------------------- /manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "HTML Comments Finder", 3 | "description": "Finds HTML comments in the current page", 4 | "version": "1.0.2", 5 | "manifest_version": 3, 6 | "homepage_url": "https://github.com/dimdenGD/html-comment-finder", 7 | "background": { 8 | "service_worker": "background.js" 9 | }, 10 | "permissions": ["activeTab"], 11 | "icons": { 12 | "128": "/images/eye_open.png" 13 | }, 14 | "action": { 15 | "default_icon": { 16 | "128": "/images/eye_closed.png" 17 | }, 18 | "default_title": "See HTML comments", 19 | "default_popup": "popup.html" 20 | }, 21 | "content_scripts": [ 22 | { 23 | "matches": [""], 24 | "js": ["content_script.js"], 25 | "run_at": "document_idle" 26 | } 27 | ] 28 | } -------------------------------------------------------------------------------- /popup.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | HTML Comment Finder 8 | 17 | 18 | 19 |

HTML Comment Finder

20 | 21 |
22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /popup.js: -------------------------------------------------------------------------------- 1 | async function getCurrentTab() { 2 | let queryOptions = { active: true, lastFocusedWindow: true }; 3 | let [tab] = await chrome.tabs.query(queryOptions); 4 | return tab; 5 | } 6 | 7 | let noComments = document.getElementById('no-comments'); 8 | let commentsElement = document.getElementById('comments'); 9 | 10 | (async () => { 11 | let tab = await getCurrentTab(); 12 | let comments = await chrome.tabs.sendMessage(tab.id, { action: "get" }); 13 | if(!comments) comments = []; 14 | 15 | noComments.hidden = comments.length > 0; 16 | commentsElement.innerHTML = ""; 17 | 18 | for(let comment of comments) { 19 | let li = document.createElement('li'); 20 | li.innerText = comment; 21 | commentsElement.appendChild(li); 22 | } 23 | })(); --------------------------------------------------------------------------------