PageSourceSearch

https://www.discourse.org/a/js/create-site-params.js?v=20260923144455

js discourse.org collected 2026-09-24 06:54:59 UTC 898 bytes, 31 lines download raw bytes

1(function () {
2  const CREATE_SITE_SELECTOR = 'a[href*="id.discourse.com/create-site"]';
3  const COOKIE_NAMES = { coupon_code: "coupon", referral_code: "referral" };
4
5  const cookies = document.cookie.split(";");
6  const params = {};
7
8  for (let i = 0; i < cookies.length; i++) {
9    const parts = cookies[i].trim().split("=");
10    const name = parts[0];
11    const value = parts.slice(1).join("=");
12    if (COOKIE_NAMES[name] && value) {
13      params[COOKIE_NAMES[name]] = decodeURIComponent(value);
14    }
15  }
16
17  if (Object.keys(params).length === 0) {
18    return;
19  }
20
21  const links = document.querySelectorAll(CREATE_SITE_SELECTOR);
22  for (let j = 0; j < links.length; j++) {
23    const url = new URL(links[j].href);
24    for (const key in params) {
25      if (!url.searchParams.has(key)) {
26        url.searchParams.set(key, params[key]);
27      }
28    }
29    links[j].href = url.toString();
30  }
31})();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.