Pleroma: username detection by request body
This commit is contained in:
parent
a92434d3da
commit
94f0903614
2 changed files with 8 additions and 2 deletions
|
@ -170,7 +170,7 @@ async function onTabUpdate(tabId, changeInfo) {
|
|||
function init() {
|
||||
NetworkTools.webRequestListen(["http://*/*", "https://*/*"], "onBeforeRequest", (requestDetails) => {
|
||||
return handleWebRequest(requestDetails).catch(handleError).catch(console.error);
|
||||
});
|
||||
}, ["requestBody"]);
|
||||
|
||||
browser.tabs.onUpdated.addListener(onTabUpdate, {
|
||||
properties: ["url"]
|
||||
|
|
|
@ -110,6 +110,12 @@ export function getTootUrl(url) {
|
|||
export function getUsername(url, requestDetails) {
|
||||
redirectSiteFinishedLoading = false;
|
||||
|
||||
try {
|
||||
return requestDetails.requestBody.formData.nickname[0];
|
||||
} catch (e) {
|
||||
console.error("Could not get username from request body. Error: ", e);
|
||||
}
|
||||
|
||||
try {
|
||||
const originUrl = new URL(requestDetails.originUrl);
|
||||
const match = USER_PAGE_URL_REGEX.exec(originUrl.pathname);
|
||||
|
@ -122,7 +128,7 @@ export function getUsername(url, requestDetails) {
|
|||
console.error("Could not get valid username from request details. Got", originUrl, "from", requestDetails);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Could not get username from request details. Error: ", e);
|
||||
console.error("Could not get username from request origin. Error: ", e);
|
||||
}
|
||||
|
||||
// fallback to HTML scraping
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue