Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想创建一个 chrome 扩展来获取页面中的所有链接并显示它们。我可以在 javascript 中使用 DOM 模型吗?还是我必须使用 xmlHttpRequest(AJAX)?
尝试这个:
chrome.tabs.executeScript({code: 'console.log(document.getElementsByTagName("a"));'});
Chrome 扩展可以完全访问 DOM,所以只需使用 Javascript 获取它们就可以了。我可以建议使用 TamperMonkey 扩展对其进行试验,这将在测试内容时缩短您的往返行程。