Created
November 23, 2020 17:12
-
-
Save chattybot0/a45525a8df2a6d45777043d380d551a2 to your computer and use it in GitHub Desktop.
Inject scripts into webpage
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 script = document.createElement('script'); | |
script.id = "injframework"; | |
script.appendChild(document.createTextNode(` | |
console.rawLogs = ""; | |
console.rawLog = function(){ | |
return console.rawLogs; | |
} | |
console.defaultLog = console.log.bind(console); | |
console.logs = []; | |
console.log = function(){ | |
console.rawLogs += \` | |
\` + arguments[0]; | |
console.defaultLog.apply(console, arguments); | |
console.logs.push(Array.from(arguments)); | |
} | |
console.defaultError = console.error.bind(console); | |
console.errors = []; | |
console.error = function(){ | |
console.rawLogs += \` | |
\` + arguments[0]; | |
console.defaultError.apply(console, Arra.from(arguments)); | |
console.errors.push(Array.from(arguments)); | |
} | |
console.defaultWarn = console.warn.bind(console); | |
console.warns = []; | |
console.warn = function(){ | |
console.rawLogs += \` | |
\` + arguments[0]; | |
console.defaultWarn.apply(console, arguments); | |
console.warns.push(Array.from(arguments)); | |
} | |
console.defaultClear = console.clear.bind(console); | |
console.clear = function(){ | |
console.rawLogs += \` | |
\` + arguments[0]; | |
console.logs.length = 0; | |
console.warns.length = 0; | |
console.errors.length = 0; | |
console.defaultClear(); | |
} | |
console.log("InjectFramework is successfully injected and running."); | |
`)); | |
var script2 = document.createElement('div'); | |
script2.id = "injcss"; | |
var logs = document.createElement('div'); | |
logs.id = "injhtml"; | |
(document.head||document.documentElement).appendChild(logs); | |
(document.head||document.documentElement).appendChild(script); | |
(document.head||document.documentElement).appendChild(script2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment