Detect in-app browsers — the actual reason #34 could not connect

Janie's screenshot showed the X / chevron / share / kebab chrome of TELEGRAM'S
in-app browser, not Trust's DApp browser. She tapped her sponsor's link in a
Telegram chat, Telegram opened it in its own webview, and that webview can
never hold a wallet. The page said "no wallet in this browser", she said she
was using Trust — both true, completely at cross purposes.

Our advice made it worse: "open your wallet's browser and type the address" is
useless to someone whose whole reason for being on the page is that they
tapped a link.

Now we name the browser they are actually in — Telegram, Facebook, Instagram,
LINE, Messenger, X, or a generic Android WebView — say plainly that it cannot
hold a wallet and that this is not their fault, and give them the one useful
thing: a button that copies the address to the clipboard so they can paste it
into Trust. There is an execCommand fallback because older webviews have no
clipboard API, and leaving a button that silently does nothing would be worse
than not having one.

Detection deliberately requires the absence of window.ethereum before calling
something an in-app browser: wallet browsers ARE WebViews, and those are
exactly the ones that work. Verified against Telegram, Android WebView, Trust
(correctly ignored) and mobile Safari (correctly ignored).

This will hit far more members than Janie — every link tapped inside a chat
app lands in the same trap.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
martbost
2026-08-29 06:18:35 -05:00
parent a57af32f4a
commit 8964dfcf97
6 changed files with 79 additions and 5 deletions
+74
View File
@@ -0,0 +1,74 @@
// Detects "in-app browsers" — the webviews Telegram, Facebook, Instagram and
// friends open when you tap a link inside them.
//
// Why this exists: a member taps their sponsor's link in a Telegram chat,
// Telegram opens it in its own webview, and that webview can never hold a
// wallet. The page correctly reported "no wallet in this browser" and the
// member correctly replied that they were using Trust — both true, and
// completely at cross purposes. The instruction to "open your wallet's browser"
// is useless when the reason they are here is that they tapped a link.
//
// So: name the actual browser they are in, and give them the one thing that
// actually helps — the address on their clipboard.
(function () {
'use strict';
function detect() {
var ua = navigator.userAgent || '';
// Telegram exposes a proxy object in its webview on Android, and the Mini
// App bridge on both. Far more reliable than sniffing its UA, which is a
// plain Chrome string.
if (window.TelegramWebviewProxy || (window.Telegram && window.Telegram.WebApp && !window.ethereum)) return 'Telegram';
if (/FBAN|FBAV|FB_IAB/i.test(ua)) return 'Facebook';
if (/Instagram/i.test(ua)) return 'Instagram';
if (/\bLine\//i.test(ua)) return 'LINE';
if (/\bMessenger\b/i.test(ua)) return 'Messenger';
if (/\bTwitter\b/i.test(ua)) return 'X';
// Generic Android WebView: "; wv)" is the giveaway. Only treat it as an
// in-app browser when no wallet is present, since some wallet browsers are
// themselves WebViews and those are exactly the ones that DO work.
if (/; wv\)/i.test(ua) && !window.ethereum) return 'an in-app browser';
return null;
}
window.RMCInApp = {
name: detect,
// Returns HTML for the wallet-error slot, or '' when this is a normal
// browser and the existing "open your wallet's browser" advice is right.
notice: function (pathForWallet) {
var w = detect();
if (!w) return '';
var url = 'rmcircle.team' + (pathForWallet || location.pathname);
return '<b>You’re in ' + w + '’s built-in browser</b> — it can’t hold a wallet, ' +
'so no wallet app can connect here. That’s why this isn’t working, and it’s not anything you did wrong.' +
'<div style="margin-top:10px"><button type="button" id="rmcCopyAddr" class="btn btn-primary btn-sm">' +
'Copy this page’s address</button> <span id="rmcCopiedNote" class="micro" style="margin-left:8px"></span></div>' +
'<div style="margin-top:10px;line-height:1.6">Then open <b>Trust</b> (or MetaMask / SafePal), find its ' +
'<b>Browser</b> or <b>DApps</b> tab, and paste it there. Typing <b>' + url + '</b> by hand works too.</div>';
},
// Wire the copy button after the notice is inserted.
bind: function (pathForWallet) {
var btn = document.getElementById('rmcCopyAddr');
if (!btn) return;
btn.addEventListener('click', function () {
var url = 'https://rmcircle.team' + (pathForWallet || location.pathname);
var note = document.getElementById('rmcCopiedNote');
function ok() { if (note) note.textContent = 'Copied — now paste it in your wallet’s browser.'; }
if (navigator.clipboard && navigator.clipboard.writeText) {
navigator.clipboard.writeText(url).then(ok, function () { fallback(url, ok); });
} else { fallback(url, ok); }
});
function fallback(url, done) {
// Older webviews have no clipboard API — select the text so a long-press
// copy works, rather than leaving the button doing nothing.
var t = document.createElement('textarea');
t.value = url;
t.style.cssText = 'position:fixed;left:0;top:0;opacity:0';
document.body.appendChild(t);
t.focus(); t.select();
try { document.execCommand('copy'); done(); } catch (e) {}
setTimeout(function () { document.body.removeChild(t); }, 100);
}
}
};
})();
+1 -1
View File
@@ -31,4 +31,4 @@
</section>
</main>
<footer class="wrap disclaimer">All figures are read live from the RM Circle smart contract on Polygon and are historical facts, not a promise of future results. Participation involves cryptocurrency and smart-contract risk. Never use funds you cannot afford to lose.<div class="footer-links"><a href="/">Home</a><a href="/contract">Contract Security</a><a href="/disclaimer">Disclaimers</a><a href="/tools">Promo Tools</a><a href="/privacy">Privacy</a><a href="/refunds">Refunds</a></div></footer>
<script src="/track.js"></script><script src="/qrlib.js"></script><script src="/rmc-wallet.js"></script><script src="/my.js"></script><script src="/payouts.js" defer></script><script src="/chat.js" defer></script><script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/wallet-notice.js" defer></script></body></html>
<script src="/track.js"></script><script src="/qrlib.js"></script><script src="/rmc-wallet.js"></script><script src="/inapp-browser.js"></script><script src="/my.js"></script><script src="/payouts.js" defer></script><script src="/chat.js" defer></script><script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/wallet-notice.js" defer></script></body></html>
+1 -1
View File
@@ -325,7 +325,7 @@
const err=document.getElementById('msgAuthErr');
try{
const eth=await window.RMCWallet.pick();
if(!eth){err.textContent='This browser has no wallet in it. Open this page INSIDE your wallet app instead: open Trust, MetaMask, SafePal or Coinbase, find its Browser (or DApps) tab, and type rmcircle.team/my into that address bar. On iPhone, Trust no longer has a browser — use MetaMask or SafePal, or ask your sponsor to link you instead.';return;}
if(!eth){{var _ia=(window.RMCInApp&&window.RMCInApp.notice('/my'))||'';if(_ia){err.innerHTML=_ia;if(err.style)err.style.display='block';window.RMCInApp.bind('/my');}else{err.textContent='This browser has no wallet in it. Open this page INSIDE your wallet app instead: open Trust, MetaMask, SafePal or Coinbase, find its Browser (or DApps) tab, and type rmcircle.team/my into that address bar. On iPhone, Trust no longer has a browser — use MetaMask or SafePal, or ask your sponsor to link you instead.';}}return;}
const accs=await eth.request({method:'eth_requestAccounts'});const account=accs[0];
// Match the wallet's active chain to the SIWE message's Chain ID (137),
// or the wallet rejects the signature ("chain ID does not match").
+1 -1
View File
@@ -49,6 +49,6 @@
<div class="su-foot">The Suite is included with team membership — never sold separately, never an extra cost. Tools marked "in development" ship in the order the team builds them; only what you can click today is promised today. Independent team resource · No income is guaranteed · Cryptocurrency involves risk. <a href="/how-pay-works#exact-costs" style="color:var(--teal)">Level costs, straight from the contract →</a></div>
</main>
<script src="/rmc-wallet.js"></script>
<script src="/suite.js"></script>
<script src="/inapp-browser.js"></script><script src="/suite.js"></script>
<script src="/chat.js" defer></script>
<script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/nav-dash.js" defer></script></body></html>
+1 -1
View File
@@ -105,7 +105,7 @@
btn.disabled = true; btn.textContent = 'Connecting…';
try {
var eth = await window.RMCWallet.pick();
if (!eth) { err.textContent = 'This browser has no wallet in it. Open this page INSIDE your wallet app instead: open Trust, MetaMask, SafePal or Coinbase, find its Browser (or DApps) tab, and type rmcircle.team/suite into that address bar. On iPhone, Trust no longer has a browser — use MetaMask or SafePal, or ask your sponsor to link you instead.'; err.style.display = 'block'; btn.disabled = false; btn.textContent = '🔑 Connect wallet — light up my tools'; return; }
if (!eth) { {var _ia=(window.RMCInApp&&window.RMCInApp.notice('/suite'))||'';if(_ia){err.innerHTML=_ia;if(err.style)err.style.display='block';window.RMCInApp.bind('/suite');}else{err.textContent = 'This browser has no wallet in it. Open this page INSIDE your wallet app instead: open Trust, MetaMask, SafePal or Coinbase, find its Browser (or DApps) tab, and type rmcircle.team/suite into that address bar. On iPhone, Trust no longer has a browser — use MetaMask or SafePal, or ask your sponsor to link you instead.';}} err.style.display = 'block'; btn.disabled = false; btn.textContent = '🔑 Connect wallet — light up my tools'; return; }
var accs = await eth.request({ method: 'eth_requestAccounts' });
var account = accs[0];
try { await window.RMCWallet.ensureChain(eth); } catch (ce) {}
+1 -1
View File
@@ -88,4 +88,4 @@
</div></section>
</main>
<footer class="wrap disclaimer">This is an independent RM Circle Team Build training resource. Always confirm transaction details in your wallet before signing. Never disclose your Secret Recovery Phrase.<div class="footer-links"><a href="/">Strategy</a><a href="/start">Getting Started</a><a href="/contract">Contract Security</a><a href="/admin">Team Admin</a><a href="/disclaimer">Disclaimers</a><a href="/how-pay-works">How You Get Paid</a><a href="/tools">Promo Tools</a><a href="/privacy">Privacy</a><a href="/refunds">Refunds</a></div></footer>
<script src="/track.js"></script><script src="/rmc-wallet.js"></script><script src="/training.js"></script><script src="/wallet-notice.js" defer></script><script src="/chat.js" defer></script><script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/nav-dash.js" defer></script></body></html>
<script src="/track.js"></script><script src="/rmc-wallet.js"></script><script src="/inapp-browser.js"></script><script src="/training.js"></script><script src="/wallet-notice.js" defer></script><script src="/chat.js" defer></script><script src="/translate.js" defer></script><script src="/tg-app.js" defer></script><script src="/nav-dash.js" defer></script></body></html>