aboutsummaryrefslogtreecommitdiffhomepage
path: root/example/ios/iOS UI Test/iOS UI Test/MCOMessageViewScript.js
blob: 37d6064975f5e6d36a73f16e6f676db6cbb48e15 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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(info) {
	var images = imageElements();
	
	for (var i = 0; i < images.length; i++) {
		var url = images[i].getAttribute('src');
		if (url.indexOf(info.URLKey) == 0) {
			images[i].setAttribute('src', info.LocalPathKey);
			break;
		}
	}
}