天天看點

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)

某網站有彩蛋啊:每一個星球都有一個驅動核心,每一種思想都有影響力的種子。感受世界的溫度,年輕的你也能成為改變世界的動力,□□珍惜你所有的潛力。你的潛力,是改變世界的動力!