CFRMessageProvider.jsm 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
  4. "use strict";
  5. const FACEBOOK_CONTAINER_PARAMS = {
  6. existing_addons: ["@contain-facebook", "{bb1b80be-e6b3-40a1-9b6e-9d4073343f0b}", "{a50d61ca-d27b-437a-8b52-5fd801a0a88b}"],
  7. open_urls: ["www.facebook.com", "facebook.com"],
  8. sumo_path: "extensionrecommendations",
  9. min_frecency: 10000,
  10. };
  11. const GOOGLE_TRANSLATE_PARAMS = {
  12. existing_addons: ["jid1-93WyvpgvxzGATw@jetpack", "{087ef4e1-4286-4be6-9aa3-8d6c420ee1db}", "{4170faaa-ee87-4a0e-b57a-1aec49282887}", "jid1-TMndP6cdKgxLcQ@jetpack",
  13. "s3google@translator", "{9c63d15c-b4d9-43bd-b223-37f0a1f22e2a}", "translator@zoli.bod", "{8cda9ce6-7893-4f47-ac70-a65215cec288}", "simple-translate@sienori", "@translatenow",
  14. "{a79fafce-8da6-4685-923f-7ba1015b8748})", "{8a802b5a-eeab-11e2-a41d-b0096288709b}", "jid0-fbHwsGfb6kJyq2hj65KnbGte3yT@jetpack", "storetranslate.plugin@gmail.com",
  15. "jid1-r2tWDbSkq8AZK1@jetpack", "{b384b75c-c978-4c4d-b3cf-62a82d8f8f12}", "jid1-f7dnBeTj8ElpWQ@jetpack", "{dac8a935-4775-4918-9205-5c0600087dc4}", "gtranslation2@slam.com",
  16. "{e20e0de5-1667-4df4-bd69-705720e37391}", "{09e26ae9-e9c1-477c-80a6-99934212f2fe}", "mgxtranslator@magemagix.com", "gtranslatewins@mozilla.org"],
  17. open_urls: ["translate.google.com"],
  18. sumo_path: "extensionrecommendations",
  19. min_frecency: 10000,
  20. };
  21. const YOUTUBE_ENHANCE_PARAMS = {
  22. existing_addons: ["enhancerforyoutube@maximerf.addons.mozilla.org", "{dc8f61ab-5e98-4027-98ef-bb2ff6060d71}", "{7b1bf0b6-a1b9-42b0-b75d-252036438bdc}", "jid0-UVAeBCfd34Kk5usS8A1CBiobvM8@jetpack",
  23. "iridium@particlecore.github.io", "jid1-ss6kLNCbNz6u0g@jetpack", "{1cf918d2-f4ea-4b4f-b34e-455283fef19f}"],
  24. open_urls: ["www.youtube.com", "youtube.com"],
  25. sumo_path: "extensionrecommendations",
  26. min_frecency: 10000,
  27. };
  28. const WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS = {
  29. existing_addons: ["@wikipediacontextmenusearch", "{ebf47fc8-01d8-4dba-aa04-2118402f4b20}", "{5737a280-b359-4e26-95b0-adec5915a854}", "olivier.debroqueville@gmail.com", "{3923146e-98cb-472b-9c13-f6849d34d6b8}"],
  30. open_urls: ["www.wikipedia.org", "wikipedia.org"],
  31. sumo_path: "extensionrecommendations",
  32. min_frecency: 10000,
  33. };
  34. const REDDIT_ENHANCEMENT_PARAMS = {
  35. existing_addons: ["jid1-xUfzOsOFlzSOXg@jetpack"],
  36. open_urls: ["www.reddit.com", "reddit.com"],
  37. sumo_path: "extensionrecommendations",
  38. min_frecency: 10000,
  39. };
  40. const PINNED_TABS_TARGET_SITES = [
  41. "docs.google.com", "www.docs.google.com", "calendar.google.com",
  42. "messenger.com", "www.messenger.com", "web.whatsapp.com", "mail.google.com",
  43. "outlook.live.com", "facebook.com", "www.facebook.com", "twitter.com", "www.twitter.com",
  44. "reddit.com", "www.reddit.com", "github.com", "www.github.com", "youtube.com", "www.youtube.com",
  45. "feedly.com", "www.feedly.com", "drive.google.com", "amazon.com", "www.amazon.com",
  46. "messages.android.com", "amazon.ca", "www.amazon.ca", "amazon.com.au", "www.amazon.com.au",
  47. "amazon.co.uk", "www.amazon.co.uk", "amazon.fr", "www.amazon.fr", "amazon.de", "www.amazon.de",
  48. ];
  49. const PINNED_TABS_TARGET_LOCALES = ["en-US", "en-CA", "en-AU", "en-GB", "en-ZA", "en-NZ", "fr", "de"];
  50. const CFR_MESSAGES = [
  51. {
  52. id: "FACEBOOK_CONTAINER_3",
  53. template: "cfr_doorhanger",
  54. content: {
  55. category: "cfrAddons",
  56. bucket_id: "CFR_M1",
  57. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  58. heading_text: {string_id: "cfr-doorhanger-extension-heading"},
  59. info_icon: {
  60. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  61. sumo_path: FACEBOOK_CONTAINER_PARAMS.sumo_path,
  62. },
  63. addon: {
  64. id: "954390",
  65. title: "Facebook Container",
  66. icon: "resource://activity-stream/data/content/assets/cfr_fb_container.png",
  67. rating: 4.6,
  68. users: 299019,
  69. author: "Mozilla",
  70. amo_url: "https://addons.mozilla.org/firefox/addon/facebook-container/",
  71. },
  72. text: "Stop Facebook from tracking your activity across the web. Use Facebook the way you normally do without annoying ads following you around.",
  73. buttons: {
  74. primary: {
  75. label: {string_id: "cfr-doorhanger-extension-ok-button"},
  76. action: {
  77. type: "INSTALL_ADDON_FROM_URL",
  78. data: {url: null},
  79. },
  80. },
  81. secondary: [{
  82. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  83. action: {type: "CANCEL"},
  84. }, {
  85. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  86. }, {
  87. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  88. action: {
  89. type: "OPEN_PREFERENCES_PAGE",
  90. data: {category: "general-cfraddons"},
  91. },
  92. }],
  93. },
  94. },
  95. frequency: {lifetime: 3},
  96. targeting: `
  97. localeLanguageCode == "en" &&
  98. (xpinstallEnabled == true) &&
  99. (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
  100. (${JSON.stringify(FACEBOOK_CONTAINER_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${FACEBOOK_CONTAINER_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
  101. trigger: {id: "openURL", params: FACEBOOK_CONTAINER_PARAMS.open_urls},
  102. },
  103. {
  104. id: "GOOGLE_TRANSLATE_3",
  105. template: "cfr_doorhanger",
  106. content: {
  107. category: "cfrAddons",
  108. bucket_id: "CFR_M1",
  109. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  110. heading_text: {string_id: "cfr-doorhanger-extension-heading"},
  111. info_icon: {
  112. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  113. sumo_path: GOOGLE_TRANSLATE_PARAMS.sumo_path,
  114. },
  115. addon: {
  116. id: "445852",
  117. title: "To Google Translate",
  118. icon: "resource://activity-stream/data/content/assets/cfr_google_translate.png",
  119. rating: 4.1,
  120. users: 313474,
  121. author: "Juan Escobar",
  122. amo_url: "https://addons.mozilla.org/firefox/addon/to-google-translate/",
  123. },
  124. text: "Instantly translate any webpage text. Simply highlight the text, right-click to open the context menu, and choose a text or aural translation.",
  125. buttons: {
  126. primary: {
  127. label: {string_id: "cfr-doorhanger-extension-ok-button"},
  128. action: {
  129. type: "INSTALL_ADDON_FROM_URL",
  130. data: {url: null},
  131. },
  132. },
  133. secondary: [{
  134. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  135. action: {type: "CANCEL"},
  136. }, {
  137. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  138. }, {
  139. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  140. action: {
  141. type: "OPEN_PREFERENCES_PAGE",
  142. data: {category: "general-cfraddons"},
  143. },
  144. }],
  145. },
  146. },
  147. frequency: {lifetime: 3},
  148. targeting: `
  149. localeLanguageCode == "en" &&
  150. (xpinstallEnabled == true) &&
  151. (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
  152. (${JSON.stringify(GOOGLE_TRANSLATE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${GOOGLE_TRANSLATE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
  153. trigger: {id: "openURL", params: GOOGLE_TRANSLATE_PARAMS.open_urls},
  154. },
  155. {
  156. id: "YOUTUBE_ENHANCE_3",
  157. template: "cfr_doorhanger",
  158. content: {
  159. category: "cfrAddons",
  160. bucket_id: "CFR_M1",
  161. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  162. heading_text: {string_id: "cfr-doorhanger-extension-heading"},
  163. info_icon: {
  164. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  165. sumo_path: YOUTUBE_ENHANCE_PARAMS.sumo_path,
  166. },
  167. addon: {
  168. id: "700308",
  169. title: "Enhancer for YouTube\u2122",
  170. icon: "resource://activity-stream/data/content/assets/cfr_enhancer_youtube.png",
  171. rating: 4.8,
  172. users: 357328,
  173. author: "Maxime RF",
  174. amo_url: "https://addons.mozilla.org/firefox/addon/enhancer-for-youtube/",
  175. },
  176. text: "Take control of your YouTube experience. Automatically block annoying ads, set playback speed and volume, remove annotations, and more.",
  177. buttons: {
  178. primary: {
  179. label: {string_id: "cfr-doorhanger-extension-ok-button"},
  180. action: {
  181. type: "INSTALL_ADDON_FROM_URL",
  182. data: {url: null},
  183. },
  184. },
  185. secondary: [{
  186. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  187. action: {type: "CANCEL"},
  188. }, {
  189. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  190. }, {
  191. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  192. action: {
  193. type: "OPEN_PREFERENCES_PAGE",
  194. data: {category: "general-cfraddons"},
  195. },
  196. }],
  197. },
  198. },
  199. frequency: {lifetime: 3},
  200. targeting: `
  201. localeLanguageCode == "en" &&
  202. (xpinstallEnabled == true) &&
  203. (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
  204. (${JSON.stringify(YOUTUBE_ENHANCE_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${YOUTUBE_ENHANCE_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
  205. trigger: {id: "openURL", params: YOUTUBE_ENHANCE_PARAMS.open_urls},
  206. },
  207. {
  208. id: "WIKIPEDIA_CONTEXT_MENU_SEARCH_3",
  209. template: "cfr_doorhanger",
  210. exclude: true,
  211. content: {
  212. category: "cfrAddons",
  213. bucket_id: "CFR_M1",
  214. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  215. heading_text: {string_id: "cfr-doorhanger-extension-heading"},
  216. info_icon: {
  217. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  218. sumo_path: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.sumo_path,
  219. },
  220. addon: {
  221. id: "659026",
  222. title: "Wikipedia Context Menu Search",
  223. icon: "resource://activity-stream/data/content/assets/cfr_wiki_search.png",
  224. rating: 4.9,
  225. users: 3095,
  226. author: "Nick Diedrich",
  227. amo_url: "https://addons.mozilla.org/firefox/addon/wikipedia-context-menu-search/",
  228. },
  229. text: "Get to a Wikipedia page fast, from anywhere on the web. Just highlight any webpage text and right-click to open the context menu to start a Wikipedia search.",
  230. buttons: {
  231. primary: {
  232. label: {string_id: "cfr-doorhanger-extension-ok-button"},
  233. action: {
  234. type: "INSTALL_ADDON_FROM_URL",
  235. data: {url: null},
  236. },
  237. },
  238. secondary: [{
  239. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  240. action: {type: "CANCEL"},
  241. }, {
  242. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  243. }, {
  244. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  245. action: {
  246. type: "OPEN_PREFERENCES_PAGE",
  247. data: {category: "general-cfraddons"},
  248. },
  249. }],
  250. },
  251. },
  252. frequency: {lifetime: 3},
  253. targeting: `
  254. localeLanguageCode == "en" &&
  255. (xpinstallEnabled == true) &&
  256. (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
  257. (${JSON.stringify(WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
  258. trigger: {id: "openURL", params: WIKIPEDIA_CONTEXT_MENU_SEARCH_PARAMS.open_urls},
  259. },
  260. {
  261. id: "REDDIT_ENHANCEMENT_3",
  262. template: "cfr_doorhanger",
  263. exclude: true,
  264. content: {
  265. category: "cfrAddons",
  266. bucket_id: "CFR_M1",
  267. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  268. heading_text: {string_id: "cfr-doorhanger-extension-heading"},
  269. info_icon: {
  270. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  271. sumo_path: REDDIT_ENHANCEMENT_PARAMS.sumo_path,
  272. },
  273. addon: {
  274. id: "387429",
  275. title: "Reddit Enhancement Suite",
  276. icon: "resource://activity-stream/data/content/assets/cfr_reddit_enhancement.png",
  277. rating: 4.6,
  278. users: 258129,
  279. author: "honestbleeps",
  280. amo_url: "https://addons.mozilla.org/firefox/addon/reddit-enhancement-suite/",
  281. },
  282. text: "New features include Inline Image Viewer, Never Ending Reddit (never click 'next page' again), Keyboard Navigation, Account Switcher, and User Tagger.",
  283. buttons: {
  284. primary: {
  285. label: {string_id: "cfr-doorhanger-extension-ok-button"},
  286. action: {
  287. type: "INSTALL_ADDON_FROM_URL",
  288. data: {url: null},
  289. },
  290. },
  291. secondary: [{
  292. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  293. action: {type: "CANCEL"},
  294. }, {
  295. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  296. }, {
  297. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  298. action: {
  299. type: "OPEN_PREFERENCES_PAGE",
  300. data: {category: "general-cfraddons"},
  301. },
  302. }],
  303. },
  304. },
  305. frequency: {lifetime: 3},
  306. targeting: `
  307. localeLanguageCode == "en" &&
  308. (xpinstallEnabled == true) &&
  309. (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.existing_addons)} intersect addonsInfo.addons|keys)|length == 0 &&
  310. (${JSON.stringify(REDDIT_ENHANCEMENT_PARAMS.open_urls)} intersect topFrecentSites[.frecency >= ${REDDIT_ENHANCEMENT_PARAMS.min_frecency}]|mapToProperty('host'))|length > 0`,
  311. trigger: {id: "openURL", params: REDDIT_ENHANCEMENT_PARAMS.open_urls},
  312. },
  313. {
  314. id: "PIN_TAB",
  315. template: "cfr_doorhanger",
  316. content: {
  317. category: "cfrFeatures",
  318. bucket_id: "CFR_PIN_TAB",
  319. notification_text: {string_id: "cfr-doorhanger-extension-notification"},
  320. heading_text: {string_id: "cfr-doorhanger-pintab-heading"},
  321. info_icon: {
  322. label: {string_id: "cfr-doorhanger-extension-sumo-link"},
  323. sumo_path: REDDIT_ENHANCEMENT_PARAMS.sumo_path,
  324. },
  325. text: {string_id: "cfr-doorhanger-pintab-description"},
  326. descriptionDetails: {
  327. steps: [
  328. {"string_id": "cfr-doorhanger-pintab-step1"},
  329. {"string_id": "cfr-doorhanger-pintab-step2"},
  330. {"string_id": "cfr-doorhanger-pintab-step3"},
  331. ],
  332. },
  333. buttons: {
  334. primary: {
  335. label: {string_id: "cfr-doorhanger-pintab-ok-button"},
  336. action: {
  337. type: "PIN_CURRENT_TAB",
  338. },
  339. },
  340. secondary: [{
  341. label: {string_id: "cfr-doorhanger-extension-cancel-button"},
  342. action: {type: "CANCEL"},
  343. }, {
  344. label: {string_id: "cfr-doorhanger-extension-never-show-recommendation"},
  345. }, {
  346. label: {string_id: "cfr-doorhanger-extension-manage-settings-button"},
  347. action: {
  348. type: "OPEN_PREFERENCES_PAGE",
  349. data: {category: "general-cfrfeatures"},
  350. },
  351. }],
  352. },
  353. },
  354. targeting: `locale in ${JSON.stringify(PINNED_TABS_TARGET_LOCALES)} && !hasPinnedTabs && recentVisits[.timestamp > (currentDate|date - 3600 * 1000 * 1)]|length >= 3`,
  355. frequency: {lifetime: 3},
  356. trigger: {id: "frequentVisits", params: PINNED_TABS_TARGET_SITES},
  357. },
  358. ];
  359. const CFRMessageProvider = {
  360. getMessages() {
  361. return CFR_MESSAGES.filter(msg => !msg.exclude);
  362. },
  363. };
  364. this.CFRMessageProvider = CFRMessageProvider;
  365. const EXPORTED_SYMBOLS = ["CFRMessageProvider"];