Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix: allow Discord management on message links

Emre Sokullu8e5048a3cbca
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index 9d319dce6..39a057872 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -5876,7 +5876,7 @@
const verifiedDiscordManagementControl = (clicked) => {
if (params.adapterName !== 'discord'
|| !/^(?:www\.)?discord\.com$/.test(location.hostname)
- || !/^\/channels\/(?:\d+|@me)(?:\/\d+)?\/?$/.test(location.pathname)) return false;
+ || !/^\/channels\/(?:\d+|@me)(?:\/\d+){0,2}\/?$/.test(location.pathname)) return false;
const control = _composedClosestElement(clicked,
'button,a[href],input,select,textarea,[role="textbox"],[role="button"],[role="menuitem"],[role="tab"],[role="treeitem"],[role="switch"],[role="radio"],[role="checkbox"]');
if (!control || !visible(control) || control.disabled
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index 6c38f942b..e43464e27 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -4954,7 +4954,7 @@
const verifiedDiscordManagementControl = (clicked) => {
if (params.adapterName !== 'discord'
|| !/^(?:www\.)?discord\.com$/.test(location.hostname)
- || !/^\/channels\/(?:\d+|@me)(?:\/\d+)?\/?$/.test(location.pathname)) return false;
+ || !/^\/channels\/(?:\d+|@me)(?:\/\d+){0,2}\/?$/.test(location.pathname)) return false;
const control = _composedClosestElement(clicked,
'button,a[href],input,select,textarea,[role="textbox"],[role="button"],[role="menuitem"],[role="tab"],[role="treeitem"],[role="switch"],[role="radio"],[role="checkbox"]');
if (!control || !visible(control) || control.disabled
diff --git a/test/discord-guard.mjs b/test/discord-guard.mjs
index c98213964..0b01a39bc 100644
--- a/test/discord-guard.mjs
+++ b/test/discord-guard.mjs
@@ -94,6 +94,19 @@ for (const [kind, engine, AgentClass, policy] of [
for(const selector of ['#create','#category','#channel','#edit']) assert.equal(await guard('click',{selector}),null);
} finally {await page.close();}
});
+ await t.test('Discord management controls remain available on message permalink routes',async()=>{
+ const {page,guard,probe}=await setup();
+ try {
+ for(const path of ['/channels/123/456/789','/channels/@me/456/789']) {
+ await page.evaluate(path=>history.replaceState(null,'',path),path);
+ for(const selector of ['#user-settings-trigger','#server']) {
+ const classified=await probe('click',{selector});
+ assert.equal(classified.nonMessagingTarget,true,JSON.stringify({path,selector,classified}));
+ assert.equal(await guard('click',{selector}),null,`${path} ${selector}`);
+ }
+ }
+ } finally {await page.close();}
+ });
await t.test('only the known server menu entries bypass message classification',async()=>{
const {page,guard,probe}=await setup(`<div role="menu" id="guild-header-popout">
<div role="menuitem" id="guild-header-popout-settings">Server Settings</div>