Created
May 2, 2022 11:52
-
-
Save shivergard/a9c0c0d18303e9b304876ded604f77f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chrome.tabs.onUpdated.addListener(function tabulator(tab){ | |
const your_tab_Id = tab; | |
console.log(tab); | |
chrome.tabs.update(your_tab_Id, {active: true}); | |
console.log(your_tab_Id); | |
// Execute code on the existing tab to open the Message. | |
chrome.scripting.executeScript({ | |
target: { tabId: your_tab_Id, allFrames: true }, | |
files: ['fakemask.js'] | |
// code: "window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }};" | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
var yourCustomJavaScriptCode = "window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }};"; | |
var script = document.createElement('script'); | |
var code = document.createTextNode('(function() {' + yourCustomJavaScriptCode + '})();'); | |
//#script.appendChild(code); | |
//document.body || document.head).appendChild(script); | |
globalThis.ethereum = window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }}; | |
console.log(window); | |
console.log(globalThis); | |
;(function() { | |
function script() { | |
// your main code here | |
window.ethereum = window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }}; | |
} | |
function inject(fn) { | |
const script = document.createElement('script') | |
script.text = `(${fn.toString()})();` | |
document.documentElement.appendChild(script) | |
} | |
inject(script) | |
})() | |
**/ | |
/** | |
function codeToInject() { | |
// Do here whatever your script requires. For example: | |
window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }}; | |
} | |
function embed(fn) { | |
const script = document.createElement("script"); | |
script.text = `(${fn.toString()})();`; | |
document.documentElement.appendChild(script); | |
} | |
embed(codeToInject); | |
**/ | |
function injectScript(file_path, tag) { | |
//var node = document.getElementsByTagName(tag)[0]; | |
var script = document.createElement('script'); | |
script.setAttribute('type', 'text/javascript'); | |
script.setAttribute('src', file_path); | |
document.documentElement.appendChild(script); | |
} | |
console.log(chrome.runtime.getURL('palinfake.js')); | |
injectScript(chrome.runtime.getURL('palinfake.js'), 'body'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"manifest_version": 3, | |
"name": "FakeMask", | |
"version": "0.1.0", | |
"description": "I am faking MetaMask cheap as codemonkey", | |
"background": { | |
"service_worker": "background.js" | |
}, | |
"permissions": [ | |
"tabs", | |
"scripting" | |
], | |
"content_scripts": [ | |
{ | |
"matches": [ | |
"http://*/*", | |
"https://*/*" | |
], | |
"js": ["fakemask.js"], | |
"run_at": "document_start" | |
} | |
], | |
"host_permissions": [ | |
"http://*/*", | |
"https://*/*" | |
], | |
"web_accessible_resources": [ | |
{ | |
"resources": ["palinfake.js"], | |
"matches": [ | |
"http://*/*", | |
"https://*/*" | |
] | |
} | |
], | |
"action": {} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.ethereum = {request: function point1(){ return { catch: function point2(){ return ['gatis'];}}; }}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment