diff options
Diffstat (limited to 'example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js')
-rw-r--r-- | example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js b/example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js new file mode 100644 index 00000000..67510c74 --- /dev/null +++ b/example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js @@ -0,0 +1,29 @@ + +var imageElements = function() { + var imageNodes = document.getElementsByTagName('img'); + return [].slice.call(imageNodes); +} + +var findCIDImageURL = function() { + var images = imageElements(); + + var imgLinks = []; + for (var i = 0; i < images.length; i++) { + var url = images[i].getAttribute('src'); + if (url.indexOf('cid:') == 0 || url.indexOf('x-mailcore-image:') == 0) + imgLinks.push(url); + } + return JSON.stringify(imgLinks); +} + +var replaceImageSrc = function(original, local) { + var images = imageElements(); + + for (var i = 0; i < images.length; i++) { + var url = images[i].getAttribute('src'); + if (url.indexOf(original) == 0) { + images[i].setAttribute('src', local); + break; + } + } +} |