Left: | ||
Right: |
OLD | NEW |
---|---|
1 /* | 1 /* |
2 * This file is part of Adblock Plus <http://adblockplus.org/>, | 2 * This file is part of Adblock Plus <http://adblockplus.org/>, |
3 * Copyright (C) 2006-2014 Eyeo GmbH | 3 * Copyright (C) 2006-2014 Eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
97 return Prefs.documentation_link | 97 return Prefs.documentation_link |
98 .replace(/%LINK%/g, page) | 98 .replace(/%LINK%/g, page) |
99 .replace(/%LANG%/g, Utils.appLocale); | 99 .replace(/%LANG%/g, Utils.appLocale); |
100 } | 100 } |
101 | 101 |
102 function initTranslations() | 102 function initTranslations() |
103 { | 103 { |
104 // Map message ID to HTML element ID | 104 // Map message ID to HTML element ID |
105 var mapping = { | 105 var mapping = { |
106 "title-main": "first-run-title-install", | 106 "title-main": "first-run-title-install", |
107 "i18n-features-heading": "first-run-features-heading", | |
108 "i18n-feature-betterSurfing": "first-run-feature-betterSurfing", | |
109 "i18n-feature-videoAds": "first-run-feature-videoAds", | |
110 "share-text1": "first-run-share1", | 107 "share-text1": "first-run-share1", |
111 "share-text2": "first-run-share2", | 108 "share-text2": "first-run-share2", |
112 "share-donate": "first-run-share2-donate", | 109 "share-donate": "first-run-share2-donate", |
113 "share2-connection": "first-run-share2-or" | 110 "share2-connection": "first-run-share2-or", |
111 "aa-title": "first-run-aa-title", | |
112 "aa-text": "first-run-aa-text" | |
114 }; | 113 }; |
115 | 114 |
116 document.title = AdblockPlus.getMessage("first-run", "first-run-title-install" ); | 115 document.title = AdblockPlus.getMessage("first-run", "first-run-title-install" ); |
117 for (var i in mapping) | 116 for (var i in mapping) |
118 { | 117 { |
119 var element = document.getElementById(i); | 118 var element = document.getElementById(i); |
120 element.innerText = AdblockPlus.getMessage("first-run", mapping[i]); | 119 element.innerHTML = AdblockPlus.getMessage("first-run", mapping[i]); |
Felix Dahlke
2014/07/24 08:04:22
This would introduce an XSS vulnerability, I'm afr
| |
121 } | 120 } |
122 } | 121 } |
123 | 122 |
124 function init() | 123 function init() |
125 { | 124 { |
126 // Choose a share text variant randomly | 125 // Choose a share text variant randomly |
127 var variant = Math.floor(Math.random() * 2) + 1; | 126 var variant = Math.floor(Math.random() * 2) + 1; |
128 var classList = document.documentElement.className.split(" "); | 127 var classList = document.documentElement.className.split(" "); |
129 classList.push("share-variant-" + variant); | 128 classList.push("share-variant-" + variant); |
130 document.documentElement.className = classList.join(" "); | 129 document.documentElement.className = classList.join(" "); |
131 | 130 |
132 initTranslations(); | 131 initTranslations(); |
133 initSocialLinks(variant); | 132 initSocialLinks(variant); |
133 setLinks("aa-text", getDocLink("acceptable_ads_criteria"), "index.html"); | |
134 | 134 |
135 var donateLink = document.getElementById("share-donate"); | 135 var donateLink = document.getElementById("share-donate"); |
136 donateLink.href = getDocLink("donate") + "&variant=" + variant; | 136 donateLink.href = getDocLink("donate") + "&variant=" + variant; |
137 } | 137 } |
138 | 138 |
139 function setLinks(id) | |
140 { | |
141 var element = document.getElementById(id); | |
142 if (!element) | |
143 { | |
144 return; | |
145 } | |
146 | |
147 var links = element.getElementsByTagName("a"); | |
148 | |
149 for (var i = 0; i < links.length; i++) | |
Felix Dahlke
2014/07/24 08:04:22
Please also check that |i < arguments.length - 1|
| |
150 { | |
151 if (typeof arguments[i + 1] == "string") | |
Felix Dahlke
2014/07/24 08:04:22
It'd be cleaner to put arguments[i + 1] in a tempo
| |
152 { | |
153 links[i].href = arguments[i + 1]; | |
154 links[i].setAttribute("target", "_blank"); | |
155 } | |
156 else if (typeof arguments[i + 1] == "function") | |
157 { | |
158 links[i].href = "javascript:void(0);"; | |
159 links[i].addEventListener("click", arguments[i + 1], false); | |
160 } | |
161 } | |
162 } | |
163 | |
139 window.addEventListener("load", init); | 164 window.addEventListener("load", init); |
OLD | NEW |