Created
July 31, 2018 12:33
-
-
Save dodikk/e028c03cd809271c950c135a3abd4240 to your computer and use it in GitHub Desktop.
Javascript injection in WKWebView
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 videoTags = document.getElementsByTagName('video'); | |
var result = []; | |
result.push('====\n') | |
for (var i = 0; i < videoTags.length; i++) | |
{ | |
// result.push("====singleVideoTag \n"); | |
var singleVideoTag = videoTags[i]; | |
var sourceChildTags = singleVideoTag.getElementsByTagName('source'); | |
for (var j = 0; j < sourceChildTags.length; j++) | |
{ | |
// result.push("==singleSourceTag \n"); | |
var singleSourceTag = sourceChildTags[j]; | |
var videoSourceUrl = | |
singleSourceTag.getAttribute('src') | |
.toString() | |
.trim() | |
.toLowerCase(); | |
result.push(videoSourceUrl); | |
var isHttp = videoSourceUrl.startsWith('http://'); | |
if (isHttp) | |
{ | |
var httpsSourceUrl = videoSourceUrl.replace('http://', 'https://'); | |
result.push(httpsSourceUrl); | |
singleSourceTag.setAttribute('src', httpsSourceUrl); | |
} | |
else | |
{ | |
result.push('http scheme not found'); | |
} | |
} | |
} | |
result.push('====\n') | |
result.toString(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment