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/. */
5 /* global MPShowMessage, MPIsEnabled, MPShouldShowHint */
9 function decodeMessageFromUrl() {
10 const url = new URL(document.location.href);
12 if (url.searchParams.has("json")) {
13 const encodedMessage = url.searchParams.get("json");
15 return atob(encodedMessage);
21 document.body.classList.add("hint-box");
22 document.body.innerHTML = `<div class="hint">Message preview is not enabled. Enable it in about:config by setting <code>browser.newtabpage.activity-stream.asrouter.devtoolsEnabled</code> to true.</div>`;
25 const message = decodeMessageFromUrl();
28 // If message preview is enabled, show the message.
30 MPShowMessage(message);
31 } else if (MPShouldShowHint()) {
32 // If running in a local build, show a hint about how to enable preview.
36 document.addEventListener("DOMContentLoaded", showHint, { once: true });