Meta Mess, a super simple yet powerful Microsoft Edge Extension

一个超简单的Microsoft Edge Extension - Fun_with_Words - 博客园 (cnblogs.com)

能在每个页面里注入JS代码,那我们有啥不能干的?我们可以弹出个窗口,输入编辑JS代码,然后在网页内执行。Ladies and gentlemen, I give you Meta Mess with jQuery enabled. :-)  https://files.cnblogs.com/files/blogs/714801/metamess.zip 

{
"name": "Meta Mess",
"version": "0.0.0.1",
"manifest_version": 2,
"description": "Mess web pages by editing and executing JS (jQuery enabled).",
"icons": {"16": "1.png", "32": "1.png", "48": "1.png"},
"browser_action": {"default_popup": "popup.html"},
"web_accessible_resources": ["*.png"],
"content_scripts": [{"matches": ["<all_urls>"],
"js": ["jquery.min.js", "injected.js"]}]
}
function query_cb(tabs){ // callback of query()
  // Send a message from the extension's popup script to any content scripts that belong to
  // the extension and are running in the specified tab.
  chrome.tabs.sendMessage(tabs[0].id, {str:ta.value}, function(response){})
}

// <button onclick=""> didn't work. Don't know why.
let d = document
d.getElementById('btn_eval').onclick = function(){
  chrome.tabs.query({active:true, currentWindow:true}, query_cb)
}
d.getElementById('btn_clear').onclick = function(){ ta.value = '' }
ta.value =
`function add_style(s){
  let d = document, e = d.createElement('style'); e.type='text/css'
  e.appendChild(d.createTextNode(s)); d.head.appendChild(e)
}
add_style('*{color:green}')
let log = console.log
for(let x of document.getElementsByTagName('pre'))log(x.innerText);
` + 'ver=$().jquery; log(`jQuery ${ver}`)' + '\n// https://www.cnblogs.com/funwithwords/category/2081251.html'
chrome.runtime.onMessage.addListener(function(req, sender, sendResponse){
    console.log(req.str); eval(req.str); sendResponse({})
})
<meta charset="utf-8"><html><head><style>
*{font:9.5pt 'Consolas', mono}
body{width:600px; padding:0px; margin:0px}
textarea{width:598px; height:25em;
 border:none; padding:2px; margin:0px;
 overflow:scroll;
}
button{width:12em; margin:4px; padding:0.5em}
</style></head><body>
<textarea id="ta" autofocus spellcheck ="false" rows="20" cols="60"></textarea><br>
<button id="btn_eval">eval(your_script)</button>
<button id="btn_clear">clear</button>
<script src="popup.js"></script>
</body></html>

海底两万里(20,000 Leagues Under the Sea) 英文版 - - 趣词英文在线小说 (quword.com)

某网站有彩蛋啊:每一个星球都有一个驱动核心,每一种思想都有影响力的种子。感受世界的温度,年轻的你也能成为改变世界的动力,□□珍惜你所有的潜力。你的潜力,是改变世界的动力!

posted @ 2021-12-16 23:30  Fun_with_Words  阅读(107)  评论(0编辑  收藏  举报









 张牌。