diff --git a/firefox/manifest.json b/firefox/manifest.json index 6156e6a..a299f8b 100644 --- a/firefox/manifest.json +++ b/firefox/manifest.json @@ -1,6 +1,6 @@ { "name": "FediAct", - "version": "0.9.8", + "version": "0.9.8.1", "description": "Simplifies interactions on other Mastodon instances than your own. Visit https://github.com/lartsch/FediAct for more.", "manifest_version": 2, "content_scripts": [ diff --git a/manifest.json b/manifest.json index 4151a11..dd5274e 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "FediAct", - "version": "0.9.8", + "version": "0.9.8.1", "description": "Simplifies interactions on other Mastodon instances than your own. Visit https://github.com/lartsch/FediAct for more.", "manifest_version": 3, "content_scripts": [ diff --git a/src/inject.js b/src/inject.js index 7400fec..51589a3 100644 --- a/src/inject.js +++ b/src/inject.js @@ -550,22 +550,24 @@ function showModal(settings) { } $("body").append($(baseEl)) $("body").on("click", function(e) { - if ($(e.target).is(".fediactmodal li, .fediactmodal li a")) { - if ($(e.target).is(".fediactmodal li")) { - e.target = $(e.target).find("a") - } - var action = $(e.target).attr("fediactaction") - var id = $(e.target).attr("fediactid") - var done = executeAction(id, action, null) - if (done) { + if (e.originalEvent.isTrusted) { + if ($(e.target).is(".fediactmodal li, .fediactmodal li a")) { + if ($(e.target).is(".fediactmodal li")) { + e.target = $(e.target).find("a") + } + var action = $(e.target).attr("fediactaction") + var id = $(e.target).attr("fediactid") + var done = executeAction(id, action, null) + if (done) { + $(baseEl).remove() + $("body").off() + } else { + alert("Failed to " + action) + } + } else { $(baseEl).remove() $("body").off() - } else { - alert("Failed to " + action) } - } else { - $(baseEl).remove() - $("body").off() } }) } @@ -897,30 +899,34 @@ async function processToots() { // prevent default and immediate propagation e.preventDefault() e.stopImmediatePropagation() - // redirect to the resolved URL + fedireply parameter (so the extension can handle it after redirect) - redirectTo(tootdata[7]+"?fedireply") + if (e.originalEvent.isTrusted) { + // redirect to the resolved URL + fedireply parameter (so the extension can handle it after redirect) + redirectTo(tootdata[7]+"?fedireply") + } }) $(moreButton).on("click", function(e){ // prevent default and immediate propagation e.preventDefault() e.stopImmediatePropagation() - var modalLinks = [] - if (isBlocked(tootdata[1])) { - modalLinks.push(["unblock",tootdata[6]]) - } else { - modalLinks.push(["block",tootdata[6]]) - } - if (isMuted(tootdata[1])) { - modalLinks.push(["unmute",tootdata[6]]) - } else { - modalLinks.push(["mute",tootdata[6]]) - } - if (isDomainBlocked(tootdata[1])) { - modalLinks.push(["domainunblock",domain]) - } else { - modalLinks.push(["domainblock",domain]) + if (e.originalEvent.isTrusted) { + var modalLinks = [] + if (isBlocked(tootdata[1])) { + modalLinks.push(["unblock",tootdata[6]]) + } else { + modalLinks.push(["block",tootdata[6]]) + } + if (isMuted(tootdata[1])) { + modalLinks.push(["unmute",tootdata[6]]) + } else { + modalLinks.push(["mute",tootdata[6]]) + } + if (isDomainBlocked(tootdata[1])) { + modalLinks.push(["domainunblock",domain]) + } else { + modalLinks.push(["domainblock",domain]) + } + showModal(modalLinks) } - showModal(modalLinks) }) // for all other buttons... $([favButton, boostButton, bookmarkButton, voteButton]).each(function() { @@ -938,12 +944,29 @@ async function processToots() { // prevent default and immediate propagation e.preventDefault() e.stopImmediatePropagation() - // increase click counter - clicks++ - // this will always run, but see below for double click handling - if (clicks == 1) { - timer = setTimeout(async function() { - if (isVote && !tootdata[10]) { + if (e.originalEvent.isTrusted) { + // increase click counter + clicks++ + // this will always run, but see below for double click handling + if (clicks == 1) { + timer = setTimeout(async function() { + if (isVote && !tootdata[10]) { + var actionExecuted = pollAction(tootdata[9], tootdata[7], e) + } else { + // execute action on click and get result (fail/success) + var actionExecuted = await tootAction(tootdata[2], e) + } + if (!actionExecuted) { + log("Action failed.") + } + // reset clicks + clicks = 0 + }, 350) + } else { + // if we get here, the element was clicked twice before the above timeout was over, so this is a double click + // reset the above timeout so it wont execute + clearTimeout(timer) + if (isVote) { var actionExecuted = pollAction(tootdata[9], tootdata[7], e) } else { // execute action on click and get result (fail/success) @@ -951,28 +974,13 @@ async function processToots() { } if (!actionExecuted) { log("Action failed.") + } else { + // redirect to home instance with the resolved toot url + redirectTo(tootdata[7]) } // reset clicks clicks = 0 - }, 350) - } else { - // if we get here, the element was clicked twice before the above timeout was over, so this is a double click - // reset the above timeout so it wont execute - clearTimeout(timer) - if (isVote) { - var actionExecuted = pollAction(tootdata[9], tootdata[7], e) - } else { - // execute action on click and get result (fail/success) - var actionExecuted = await tootAction(tootdata[2], e) } - if (!actionExecuted) { - log("Action failed.") - } else { - // redirect to home instance with the resolved toot url - redirectTo(tootdata[7]) - } - // reset clicks - clicks = 0 } }).on("dblclick", function(e) { // default dblclick event must be prevented @@ -1186,23 +1194,25 @@ async function processFollow() { // prevent default and immediate propagation e.preventDefault() e.stopImmediatePropagation() - var modalLinks = [] - if (isBlocked(fullHandle)) { - modalLinks.push(["unblock",resolvedHandle[0]]) - } else { - modalLinks.push(["block",resolvedHandle[0]]) - } - if (isMuted(fullHandle)) { - modalLinks.push(["unmute",resolvedHandle[0]]) - } else { - modalLinks.push(["mute",resolvedHandle[0]]) - } - if (isDomainBlocked(fullHandle)) { - modalLinks.push(["domainunblock",domain]) - } else { - modalLinks.push(["domainblock",domain]) + if (e.originalEvent.isTrusted) { + var modalLinks = [] + if (isBlocked(fullHandle)) { + modalLinks.push(["unblock",resolvedHandle[0]]) + } else { + modalLinks.push(["block",resolvedHandle[0]]) + } + if (isMuted(fullHandle)) { + modalLinks.push(["unmute",resolvedHandle[0]]) + } else { + modalLinks.push(["mute",resolvedHandle[0]]) + } + if (isDomainBlocked(fullHandle)) { + modalLinks.push(["domainunblock",domain]) + } else { + modalLinks.push(["domainblock",domain]) + } + showModal(modalLinks) } - showModal(modalLinks) }) // single and double click handling (see toot processing for explanation, is the same basically) var clicks = 0 @@ -1211,27 +1221,29 @@ async function processFollow() { // prevent default and immediate propagation e.preventDefault() e.stopImmediatePropagation() - clicks++ - if (clicks == 1) { - timer = setTimeout(async function() { - execFollow(resolvedHandle[0]) - clicks = 0 - }, 350) - } else { - clearTimeout(timer) - var done = await execFollow(resolvedHandle[0]) - if (done) { - var saveText = $(el).text() - var redirectUrl = 'https://' + settings.fediact_homeinstance + '/@' + resolvedHandle[1] - $(el).text("Redirecting...") - setTimeout(function() { - redirectTo(redirectUrl) - $(el).text(saveText) - }, 1000) + if (e.originalEvent.isTrusted) { + clicks++ + if (clicks == 1) { + timer = setTimeout(async function() { + execFollow(resolvedHandle[0]) + clicks = 0 + }, 350) } else { - log("Action failed.") + clearTimeout(timer) + var done = await execFollow(resolvedHandle[0]) + if (done) { + var saveText = $(el).text() + var redirectUrl = 'https://' + settings.fediact_homeinstance + '/@' + resolvedHandle[1] + $(el).text("Redirecting...") + setTimeout(function() { + redirectTo(redirectUrl) + $(el).text(saveText) + }, 1000) + } else { + log("Action failed.") + } + clicks = 0 } - clicks = 0 } }).on("dblclick", function(e) { e.preventDefault() diff --git a/src/inject.min.js b/src/inject.min.js index 00ba5aa..f2f222d 100644 --- a/src/inject.min.js +++ b/src/inject.min.js @@ -1 +1 @@ -const i=["div.account__header button.logo-button","div.public-account-header a.logo-button","div.account-card a.logo-button","div.directory-card a.icon-button","div.detailed-status a.logo-button","button.remote-button","div.account__header button.button--follow"],u=["div.account__header__tabs__name small","div.public-account-header__tabs__name small","div.detailed-status span.display-name__account","div.display-name > span","a.user-screen-name","div.profile-info-panel small"],a=/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/,I=/^(?https?:\/\/(?:\.?[a-z0-9-]+)+(?:\.[a-z]+){1})?\/?@(?\w+)(?:@(?(?:[\w-]+\.)+?\w+))?(?:\/(?\d+))?\/?$/,q=/^(?https?:\/\/(?:\.?[a-z0-9-]+)+(?:\.[a-z]+){1})(?:\/users\/)(?\w+)(?:(?:\/statuses\/)(?\d+))?\/?$/,e=!1,n="[FediAct]",o="/api/v1/instance",d="/api/v1/statuses",s="/api/v2/search",l="/api/v1/accounts",r="/api/v1/mutes",c="/api/v1/blocks",f="/api/v1/domain_blocks",p="/api/v1/polls",h=500,m=200,k='
    ',w=15e3;var browser,chrome,M={};const y={fediact_homeinstance:null,fediact_alert:!1,fediact_mode:"blacklist",fediact_whitelist:null,fediact_blacklist:null,fediact_target:"_self",fediact_autoaction:!0,fediact_token:null,fediact_redirects:!0,fediact_enabledelay:!0,fediact_hidemuted:!1,fediact_runifloggedin:!1,fediact_mutes:[],fediact_blocks:[],fediact_domainblocks:[]},z={fedireply:void 0,lasthomerequest:void 0,whitelist:void 0,blacklist:void 0,exturi:void 0,tokenheader:void 0,processed:[],processedFollow:[],isProcessing:[]};function E(t){e&&console.log(n+" "+t)}function x(){return new Promise(function(e){var t;$(document).find("script#initial-state").length?(t=$(document).find("script#initial-state").first(),JSON.parse($(t).text()).meta.access_token&&e(!0)):$(document).DOMNodeAppear(function(t){t=$(t.target);JSON.parse($(t).text()).meta.access_token&&e(!0)},"script#initial-state"),e(!1)})}!function(a){a.fn.DOMNodeAppear=function(e,i){if(!i)return!1;a(document).on("animationstart webkitAnimationStart oanimationstart MSAnimationStart",function(t){"nodeInserted"==t.originalEvent.animationName&&a(t.target).is(i)&&"function"==typeof e&&e(t)})},jQuery.fn.onAppear=jQuery.fn.DOMNodeAppear}(jQuery);var T=function(t){for(var e,i=window.location.search.substring(1).split("&"),a=0;a{setTimeout(function(){t()},h-e)}),z.lasthomerequest=t),new Promise(function(t){let e=new XMLHttpRequest;if(e.open(a,n),e.timeout=w,o)for(var i in o)e.setRequestHeader(i,o[i]);e.onload=function(){200<=this.status&&this.status<300?t(e.responseText):t(!1)},e.ontimeout=function(){E("Timed out"),t(!1)},e.onerror=function(){E("Request to "+n+" failed."),t(!1)},s?(e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify(s))):e.send()})}function A(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(t,e,i){return t.replace(new RegExp(A(e),"g"),i)}function U(t){var e;M.fediact_redirects?M.fediact_alert&&!confirm("Redirecting to "+t)||(e=window.open(t,M.fediact_target),E("Redirected to "+t),e?e.focus():E("Could not open new window. Please allow popups for this website.")):E("Redirects disabled.")}async function j(t,e,i){var a,n,o,s,r="POST";switch(e){case"domainblock":a="https://"+M.fediact_homeinstance+f+"?domain="+t,n=function(t){if(t)return!0},s=function(){b()};break;case"domainunblock":a="https://"+M.fediact_homeinstance+f+"?domain="+t,n=function(t){if(t)return!0},r="DELETE",s=function(){b()};break;case"mute":a="https://"+M.fediact_homeinstance+l+"/"+t+"/mute",n=function(t){return t.muting},s=function(){b()};break;case"unmute":a="https://"+M.fediact_homeinstance+l+"/"+t+"/unmute",n=function(t){return!t.muting},s=function(){b()};break;case"block":a="https://"+M.fediact_homeinstance+l+"/"+t+"/block",n=function(t){return t.blocking},s=function(){b()};break;case"unblock":a="https://"+M.fediact_homeinstance+l+"/"+t+"/unblock",n=function(t){return!t.blocking},s=function(){b()};break;case"vote":a="https://"+M.fediact_homeinstance+p+"/"+t+"/votes",n=function(t){return t.voted},o=i;break;case"follow":a="https://"+M.fediact_homeinstance+l+"/"+t+"/follow",n=function(t){return t.following||t.requested};break;case"boost":a="https://"+M.fediact_homeinstance+d+"/"+t+"/reblog",n=function(t){return t.reblogged};break;case"favourite":a="https://"+M.fediact_homeinstance+d+"/"+t+"/favourite",n=function(t){return t.favourited};break;case"bookmark":a="https://"+M.fediact_homeinstance+d+"/"+t+"/bookmark",n=function(t){return t.bookmarked};break;case"unfollow":a="https://"+M.fediact_homeinstance+l+"/"+t+"/unfollow",n=function(t){return!t.following&&!t.requested};break;case"unboost":a="https://"+M.fediact_homeinstance+d+"/"+t+"/unreblog",n=function(t){return!t.reblogged};break;case"unfavourite":a="https://"+M.fediact_homeinstance+d+"/"+t+"/unfavourite",n=function(t){return!t.favourited};break;case"unbookmark":a="https://"+M.fediact_homeinstance+d+"/"+t+"/unbookmark",n=function(t){return!t.bookmarked};break;default:E("No valid action specified.")}if(a){var c=await g(r,a,z.tokenheader,o);if(c&&n(JSON.parse(c)))return void 0!==s&&s(),!0}E(e+" action failed.")}async function P(t){var e="https://"+M.fediact_homeinstance+l+"/relationships?";for(const o of t)e+="id[]="+o.toString()+"&";var i=await g("GET",e,z.tokenheader,null),a=Array(t.length).fill(!1);if(i)for(var i=JSON.parse(i),n=0;nt.json()),fetch("https://"+M.fediact_homeinstance+c,{headers:{Authorization:"Bearer "+M.fediact_token}}).then(t=>t.json()),fetch("https://"+M.fediact_homeinstance+f,{headers:{Authorization:"Bearer "+M.fediact_token}}).then(t=>t.json())]);t.length&&M.fediact_mutes.push(...t.map(t=>t.acct)),e.length&&M.fediact_blocks.push(...e.map(t=>t.acct)),i.length&&(M.fediact_domainblocks=i),Z()}function H(t){var i=$(k),e=$(i).find("ul");for(const n of t){var a=n[0].charAt(0).toUpperCase()+n[0].slice(1),a="
  • "+a+"
  • ";$(e).append($(a))}$("body").append($(i)),$("body").on("click",function(t){var e;!$(t.target).is(".fediactmodal li, .fediactmodal li a")||($(t.target).is(".fediactmodal li")&&(t.target=$(t.target).find("a")),e=$(t.target).attr("fediactaction"),j($(t.target).attr("fediactid"),e,null))?($(i).remove(),$("body").off()):alert("Failed to "+e)})}async function N(){$(document).DOMNodeAppear(function(t){$(t.target).find("button:has(i.fa-reply), button:has(i.fa-reply-all)").click()},"div.detailed-status__action-bar")}async function R(){function S(t){var e;return!t.startsWith("http")||(e=new URL(t),location.hostname==e.hostname)?[!1,(t=t.split("/")).pop()||t.pop()]:[!0,t]}async function e(e){$(e).is("div.detailed-status")&&$(e).closest("div.focusable").length&&(e=$(e).closest("div.focusable"));var t=function(t){if($(t).find("span.display-name__account").length)return $(t).find("span.display-name__account").first().text().trim()}($(e));if(!function(t,e){if(M.fediact_hidemuted){var i,a,n=[],o=($(t).siblings(".status__prepend").length&&(i=$(t).siblings(".status__prepend").first(),$(i).find("a").attr("href"))&&n.push($(i).find("a").attr("href").split("?")[0]),$(t).find("span.h-card").each(function(){n.push($(this).find("a").attr("href").split("?")[0])}),[]);for(a of n){var s,r=a.split("/"),r=(r=r.pop()||r.pop()).slice(1);a.startsWith("http")&&(s=new URL(a)).hostname!=z.exturi&&s.hostname!=location.hostname?o.push(r+"@"+s.hostname):o.push(r+"@"+z.exturi)}return o.some(t=>L(t))||L(e)?($(t).hide(),i&&$(i).hide(),1):void 0}}(e,t)){var i=function(t){if($(t).is(".detailed-status__wrapper"))return(e=window.location.href.split("?")[0].split("/")).pop()||e.pop();if($(t).attr("data-id"))return $(t).attr("data-id").split("-").slice(-1)[0];if($(t).closest("article[data-id], div[data-id]").length)return $(t).closest("article[data-id], div[data-id]").first().attr("data-id").split("-").slice(-1)[0];if($(t).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)").length){var e=$(t).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)").first();if($(e).attr("href")){t=$(e).attr("href");if(~t.indexOf("interact/"))return(e=t.split("?")[0].split("/")).pop()||e.pop()}}}($(e)),[a,n]=(a=$(e),$(a).find("a.status__relative-time").length?S($(a).find("a.status__relative-time").first().attr("href").split("?")[0]):$(a).find("a.detailed-status__datetime").length?S($(a).find("a.detailed-status__datetime").first().attr("href").split("?")[0]):$(a).find("a.modal-button").length?S($(a).find("a.modal-button").first().attr("href").split("?")[0]):[!1,void 0]),o=i||n;if(o){var s=[],r=X(o),c=$(e).find("button:has(i.fa-star)").first(),d=($(c).length||(c=$(e).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)")),$("Resolving...").insertAfter($(c)),$(e).find("button:has(i.fa-retweet)").first()),l=($(d).length||(d=$(e).find("a.icon-button:has(i.fa-retweet), a.detailed-status__link:has(i.fa-retweet)")),$(e).find("button:has(i.fa-bookmark)").first()),u=$(e).find("button:has(i.fa-reply), button:has(i.fa-reply-all), a.icon-button:has(i.fa-reply), a.icon-button:has(i.fa-reply-all)").first(),f=$(e).find("div.poll button").first(),p=$(e).find("button:has(i.fa-ellipsis-h,i.fa-ellipsis-fw,i.fa-ellipsis-v)").first();async function h(t,e,i){if(M.fediact_autoaction){for(var a={choices:[]},n=$(i.currentTarget).closest("div.poll"),o=$(n).find("li"),s=0;sView the results on your home instance.

    "),r)&&(z.processed[r][10]=!0,z.processed[r][11]=!0),t}}async function m(t,e){if(!M.fediact_autoaction)return E("Auto-action disabled."),!0;a=e,i=!1,$(a.currentTarget).children("i.fa-retweet").length?i=$(a.currentTarget).children("i.fa-retweet").hasClass("fediactive")?"unboost":"boost":$(a.currentTarget).children("i.fa-star").length?i=$(a.currentTarget).hasClass("fediactive")?"unfavourite":"favourite":$(a.currentTarget).children("i.fa-bookmark").length?i=$(a.currentTarget).hasClass("fediactive")?"unbookmark":"bookmark":$(a.currentTarget).attr("href")&&(~$(a.currentTarget).attr("href").indexOf("type=reblog")?i=$(a.currentTarget).hasClass("fediactive")?"unboost":"boost":~$(a.currentTarget).attr("href").indexOf("type=favourite")&&(i=$(a.currentTarget).hasClass("fediactive")?"unfavourite":"favourite"));var i,a=i;if(a){if(await j(t,a,null))return r&&(z.processed[r][11]=!0),"boost"==a||"unboost"==a?(B($(e.currentTarget),[["color","!remove","rgb(140, 141, 255)"]],"fediactive"),B($(e.currentTarget).find("i"),[["transition-duration","!remove","0.9s"],["background-position","!remove","0px 100%"]],"fediactive"),r&&(z.processed[r][3]=!z.processed[r][3])):"favourite"==a||"unfavourite"==a?(B($(e.currentTarget),[["color","!remove","rgb(202, 143, 4)"]],"fediactive"),B($(e.currentTarget).find("i"),[["animation","spring-rotate-out 1s linear","spring-rotate-in 1s linear"]],"fediactive"),r&&(z.processed[r][4]=!z.processed[r][4])):(B($(e.currentTarget),[["color","!remove","rgb(255, 80, 80)"]],"fediactive"),r&&(z.processed[r][5]=!z.processed[r][5])),!0;E("Could not execute action on home instance.")}else E("Could not determine action.")}function g(t){$(e).find(".fediactunresolved").remove(),$(e).find(".fediactprocessing").remove(),t[1]?($(l).removeClass("disabled").removeAttr("disabled"),$(p).removeClass("disabled").removeAttr("disabled"),$(f).removeAttr("disabled"),t[4]&&!$(c).hasClass("fediactive")&&(B($(c),[["color","!remove","rgb(202, 143, 4)"]],"fediactive"),B($(c).find("i"),[["animation","spring-rotate-out 1s linear","spring-rotate-in 1s linear"]],"fediactive")),t[3]&&!$(d).find("i.fediactive").length&&(B($(d),[["color","!remove","rgb(140, 141, 255)"]],"fediactive"),B($(d).find("i"),[["transition-duration","!remove","0.9s"],["background-position","!remove","0px 100%"]],"fediactive")),t[5]&&!$(l).hasClass("fediactive")&&B($(l),[["color","!remove","rgb(255, 80, 80)"]],"fediactive"),t[10]&&($(f).hide(),$(f).closest("div.poll").find("ul").replaceWith("

    View the results on your home instance.

    "))):$("Unresolved").insertAfter($(c))}function v(n){var t=n[1].split("@"),e=t.pop()||t.pop();$(u).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation(),U(n[7]+"?fedireply")}),$(p).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation();t=[];F(n[1])?t.push(["unblock",n[6]]):t.push(["block",n[6]]),J(n[1])?t.push(["unmute",n[6]]):t.push(["mute",n[6]]),W(n[1])?t.push(["domainunblock",e]):t.push(["domainblock",e]),H(t)}),$([c,d,l,f]).each(function(){$(f).length&&$(f).get(0).isEqualNode($(this).get(0))&&(e=!0);var e,i,a=0;$(this).on("click",async function(t){t.preventDefault(),t.stopImmediatePropagation(),1==++a?i=setTimeout(async function(){(e&&!n[10]?h(n[9],n[7],t):await m(n[2],t))||E("Action failed."),a=0},350):(clearTimeout(i),(e?h(n[9],n[7],t):await m(n[2],t))?U(n[7]):E("Action failed."),a=0)}).on("dblclick",function(t){t.preventDefault(),t.stopImmediatePropagation()})})}if(r){var b=z.processed[r];g(b),b[1]&&v(b)}else{if(a&&s.push(n),t){var _,k,w,y=t.match(I),[x,T]=[!1,!1],A=(!y.groups.handledomain||~location.hostname.indexOf(y.groups.handledomain)||(x=!0),[i]);a||A.push(n);for(_ of A=A.filter((t,e)=>void 0!==t&&A.indexOf(t)==e))x?T||((k=await V(location.protocol+"//"+location.hostname+"/"+t+"/"+_))&&(T=!0,s.push(k),q.test(k)?(w=k.match(q)).groups.handle&&w.groups.tootid&&w.groups.domain&&s.push(w.groups.domain+"/@"+w.groups.handle+"/"+w.groups.tootid):I.test(k)&&(w=k.match(I)).groups.handle&&w.groups.tootid&&w.groups.domain&&s.push(w.groups.domain+"/users/"+w.groups.handle+"/statuses/"+w.groups.tootid)),s.push(location.protocol+"//"+location.hostname+"/"+t+"/"+_)):(s.push(location.protocol+"//"+location.hostname+"/users/"+y.groups.handle+"/statuses/"+_),s.push(location.protocol+"//"+location.hostname+"/@"+y.groups.handle+"/"+_))}if(s.length){var C,P,O,N,R,D=!1;for(C of s=s.filter((t,e)=>s.indexOf(t)==e))D||([P,O]=await Q(C),P&&(D=!0,N="https://"+M.fediact_homeinstance+"/@"+P[0]+"/"+P[1],R=[o,...P,N,!0,...O,!1]));D?(r=G(R),g(R),v(R)):(E("Failed to resolve: "+s),r=G([o,!1]),g([o,!1]))}else E("Could not identify a post URI for home resolving."),r=G([o,!1]),g([o,!1])}}else E("Could not get toot data.")}}$(document).DOMNodeAppear(async function(t){z.isProcessing.includes($(t.target).get(0))||(z.isProcessing.push($(t.target).get(0)),e($(t.target)))},"div.status, div.detailed-status"),$(document).find("div.status, div.detailed-status").each(function(){z.isProcessing.includes($(this).get(0))||(z.isProcessing.push($(this).get(0)),e($(this)))})}async function D(){async function e(a){var e,n,t,i,o,s,r="follow",c=$(a).siblings("button:has(i.fa-ellipsis-fw,i.fa-ellipsis-v,i.fa-ellipsis-h)");async function d(t){return M.fediact_autoaction?(t=await j(t,r,null),"follow"==r&&t?($(a).text("Unfollow"),r="unfollow",!0):"unfollow"==r&&t?($(a).text("Follow"),r="follow",!0):void 0):(E("Auto-action disabled."),!0)}if($(a).closest("div.account-card").length)e=$(a).closest("div.account-card").find("div.display-name > span").text().trim();else for(const l of u)if($(l).length){(e=$(l).text().trim()).split("@").length-1==1&&(e=e+"@"+z.exturi);break}e&&!z.processedFollow.includes(e)&&($("Resolving...  ").insertBefore($(a)),(n=await O(e))?(z.processedFollow.push(e),$(c).length&&$(c).removeClass("disabled").removeAttr("disabled"),t=e.split("@"),i=t.pop()||t.pop(),(await P([n[0]]))[0]&&($(a).text("Unfollow"),r="unfollow"),$(c).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation();t=[];F(e)?t.push(["unblock",n[0]]):t.push(["block",n[0]]),J(e)?t.push(["unmute",n[0]]):t.push(["mute",n[0]]),W(e)?t.push(["domainunblock",i]):t.push(["domainblock",i]),H(t)}),o=0,$(a).on("click",async function(t){var e,i;t.preventDefault(),t.stopImmediatePropagation(),1==++o?s=setTimeout(async function(){d(n[0]),o=0},350):(clearTimeout(s),await d(n[0])?(e=$(a).text(),i="https://"+M.fediact_homeinstance+"/@"+n[1],$(a).text("Redirecting..."),setTimeout(function(){U(i),$(a).text(e)},1e3)):E("Action failed."),o=0)}).on("dblclick",function(t){t.preventDefault(),t.stopImmediatePropagation()})):E("Could not resolve user home ID."),$(a).siblings(".fediactprocessing").remove())}var t=i.join(",");$(document).DOMNodeAppear(async function(t){z.isProcessing.includes($(t.target).get(0))||(z.isProcessing.push($(t.target).get(0)),e($(t.target)))},t),$(document).find(t).each(function(){z.isProcessing.includes($(this).get(0))||(z.isProcessing.push($(this).get(0)),e($(this)))})}function t(t){var e,i=[];for(e of t.split(/\r?\n/))(e=e.trim()).length&&(a.test(e)?i.push(e):E("Removed invalid domain "+e+" from blacklist/whitelist."));return[...new Set(i)]}function S(){if(null==M.fediact_homeinstance||!M.fediact_homeinstance)return E("Mastodon home instance is not set."),!1;if(!M.fediact_token)return E("No API token available. Are you logged in to your home instance? If yes, wait for 1-2 minutes and reload page."),!1;if(z.tokenheader={Authorization:"Bearer "+M.fediact_token},!a.test(M.fediact_homeinstance))return E("Instance setting is not a valid domain name."),!1;if("whitelist"==M.fediact_mode){if(z.whitelist=t(M.fediact_whitelist),z.whitelist.length<1)return E("Whitelist is empty or invalid."),!1}else z.blacklist=t(M.fediact_blacklist);return!0}async function K(){if(location.hostname==M.fediact_homeinstance&&(z.fedireply=T("fedireply"),!z.fedireply))return E("Current site is your home instance."),!1;if("whitelist"==M.fediact_mode){if($.inArray(location.hostname,z.whitelist)<0)return E("Current site is not in whitelist."),!1}else if(-1<$.inArray(location.hostname,z.blacklist))return E("Current site is in blacklist."),!1;var t=await g("GET",location.protocol+"//"+location.hostname+o,null,null);return!!t&&!(!(t=JSON.parse(t).uri)||(t.startsWith("http")?(t=new URL(t),z.exturi=t.hostname):z.exturi=t,Y()?!M.fediact_runifloggedin&&!z.fedireply&&await x()&&(E("Already logged in to this external instance."),1):(E("Could not start background process"),1)))}async function Y(){chrome.runtime.onMessage.addListener(async function(t,e,i){t.urlchanged&&(z.processed=[],z.processedFollow=[],z.isProcessing=[],await _()||location.reload()),t.updatedfedisettings&&location.reload()});try{return await chrome.runtime.sendMessage({running:!0}),!0}catch(t){E(t)}return!1}function _(){return new Promise(async function(e){try{M=await(browser||chrome).storage.local.get(y)}catch(t){E(t),e(!1)}M&&S()?e(!0):e(!1)})}async function Z(){await(browser||chrome).storage.local.set(M),await _()||location.reload()}async function tt(){await _()?await K()?(z.fedireply?N:(D(),R))():E("Will not process this site."):E("Could not load settings.")}tt(); \ No newline at end of file +const i=["div.account__header button.logo-button","div.public-account-header a.logo-button","div.account-card a.logo-button","div.directory-card a.icon-button","div.detailed-status a.logo-button","button.remote-button","div.account__header button.button--follow"],u=["div.account__header__tabs__name small","div.public-account-header__tabs__name small","div.detailed-status span.display-name__account","div.display-name > span","a.user-screen-name","div.profile-info-panel small"],a=/^([a-z0-9]+(-[a-z0-9]+)*\.)+[a-z]{2,}$/,S=/^(?https?:\/\/(?:\.?[a-z0-9-]+)+(?:\.[a-z]+){1})?\/?@(?\w+)(?:@(?(?:[\w-]+\.)+?\w+))?(?:\/(?\d+))?\/?$/,I=/^(?https?:\/\/(?:\.?[a-z0-9-]+)+(?:\.[a-z]+){1})(?:\/users\/)(?\w+)(?:(?:\/statuses\/)(?\d+))?\/?$/,e=!1,n="[FediAct]",o="/api/v1/instance",d="/api/v1/statuses",s="/api/v2/search",l="/api/v1/accounts",r="/api/v1/mutes",c="/api/v1/blocks",f="/api/v1/domain_blocks",p="/api/v1/polls",h=500,m=200,k='

      ',w=15e3;var browser,chrome,q={};const y={fediact_homeinstance:null,fediact_alert:!1,fediact_mode:"blacklist",fediact_whitelist:null,fediact_blacklist:null,fediact_target:"_self",fediact_autoaction:!0,fediact_token:null,fediact_redirects:!0,fediact_enabledelay:!0,fediact_hidemuted:!1,fediact_runifloggedin:!1,fediact_mutes:[],fediact_blocks:[],fediact_domainblocks:[]},M={fedireply:void 0,lasthomerequest:void 0,whitelist:void 0,blacklist:void 0,exturi:void 0,tokenheader:void 0,processed:[],processedFollow:[],isProcessing:[]};function z(t){e&&console.log(n+" "+t)}function T(){return new Promise(function(e){var t;$(document).find("script#initial-state").length?(t=$(document).find("script#initial-state").first(),JSON.parse($(t).text()).meta.access_token&&e(!0)):$(document).DOMNodeAppear(function(t){t=$(t.target);JSON.parse($(t).text()).meta.access_token&&e(!0)},"script#initial-state"),e(!1)})}!function(a){a.fn.DOMNodeAppear=function(e,i){if(!i)return!1;a(document).on("animationstart webkitAnimationStart oanimationstart MSAnimationStart",function(t){"nodeInserted"==t.originalEvent.animationName&&a(t.target).is(i)&&"function"==typeof e&&e(t)})},jQuery.fn.onAppear=jQuery.fn.DOMNodeAppear}(jQuery);var x=function(t){for(var e,i=window.location.search.substring(1).split("&"),a=0;a{setTimeout(function(){t()},h-e)}),M.lasthomerequest=t),new Promise(function(t){let e=new XMLHttpRequest;if(e.open(a,n),e.timeout=w,o)for(var i in o)e.setRequestHeader(i,o[i]);e.onload=function(){200<=this.status&&this.status<300?t(e.responseText):t(!1)},e.ontimeout=function(){z("Timed out"),t(!1)},e.onerror=function(){z("Request to "+n+" failed."),t(!1)},s?(e.setRequestHeader("Content-Type","application/json"),e.send(JSON.stringify(s))):e.send()})}function A(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function C(t,e,i){return t.replace(new RegExp(A(e),"g"),i)}function U(t){var e;q.fediact_redirects?q.fediact_alert&&!confirm("Redirecting to "+t)||(e=window.open(t,q.fediact_target),z("Redirected to "+t),e?e.focus():z("Could not open new window. Please allow popups for this website.")):z("Redirects disabled.")}async function j(t,e,i){var a,n,o,s,r="POST";switch(e){case"domainblock":a="https://"+q.fediact_homeinstance+f+"?domain="+t,n=function(t){if(t)return!0},s=function(){b()};break;case"domainunblock":a="https://"+q.fediact_homeinstance+f+"?domain="+t,n=function(t){if(t)return!0},r="DELETE",s=function(){b()};break;case"mute":a="https://"+q.fediact_homeinstance+l+"/"+t+"/mute",n=function(t){return t.muting},s=function(){b()};break;case"unmute":a="https://"+q.fediact_homeinstance+l+"/"+t+"/unmute",n=function(t){return!t.muting},s=function(){b()};break;case"block":a="https://"+q.fediact_homeinstance+l+"/"+t+"/block",n=function(t){return t.blocking},s=function(){b()};break;case"unblock":a="https://"+q.fediact_homeinstance+l+"/"+t+"/unblock",n=function(t){return!t.blocking},s=function(){b()};break;case"vote":a="https://"+q.fediact_homeinstance+p+"/"+t+"/votes",n=function(t){return t.voted},o=i;break;case"follow":a="https://"+q.fediact_homeinstance+l+"/"+t+"/follow",n=function(t){return t.following||t.requested};break;case"boost":a="https://"+q.fediact_homeinstance+d+"/"+t+"/reblog",n=function(t){return t.reblogged};break;case"favourite":a="https://"+q.fediact_homeinstance+d+"/"+t+"/favourite",n=function(t){return t.favourited};break;case"bookmark":a="https://"+q.fediact_homeinstance+d+"/"+t+"/bookmark",n=function(t){return t.bookmarked};break;case"unfollow":a="https://"+q.fediact_homeinstance+l+"/"+t+"/unfollow",n=function(t){return!t.following&&!t.requested};break;case"unboost":a="https://"+q.fediact_homeinstance+d+"/"+t+"/unreblog",n=function(t){return!t.reblogged};break;case"unfavourite":a="https://"+q.fediact_homeinstance+d+"/"+t+"/unfavourite",n=function(t){return!t.favourited};break;case"unbookmark":a="https://"+q.fediact_homeinstance+d+"/"+t+"/unbookmark",n=function(t){return!t.bookmarked};break;default:z("No valid action specified.")}if(a){var c=await g(r,a,M.tokenheader,o);if(c&&n(JSON.parse(c)))return void 0!==s&&s(),!0}z(e+" action failed.")}async function P(t){var e="https://"+q.fediact_homeinstance+l+"/relationships?";for(const o of t)e+="id[]="+o.toString()+"&";var i=await g("GET",e,M.tokenheader,null),a=Array(t.length).fill(!1);if(i)for(var i=JSON.parse(i),n=0;nt.json()),fetch("https://"+q.fediact_homeinstance+c,{headers:{Authorization:"Bearer "+q.fediact_token}}).then(t=>t.json()),fetch("https://"+q.fediact_homeinstance+f,{headers:{Authorization:"Bearer "+q.fediact_token}}).then(t=>t.json())]);t.length&&q.fediact_mutes.push(...t.map(t=>t.acct)),e.length&&q.fediact_blocks.push(...e.map(t=>t.acct)),i.length&&(q.fediact_domainblocks=i),Z()}function H(t){var i=$(k),e=$(i).find("ul");for(const n of t){var a=n[0].charAt(0).toUpperCase()+n[0].slice(1),a="
    • "+a+"
    • ";$(e).append($(a))}$("body").append($(i)),$("body").on("click",function(t){var e;t.originalEvent.isTrusted&&(!$(t.target).is(".fediactmodal li, .fediactmodal li a")||($(t.target).is(".fediactmodal li")&&(t.target=$(t.target).find("a")),e=$(t.target).attr("fediactaction"),j($(t.target).attr("fediactid"),e,null))?($(i).remove(),$("body").off()):alert("Failed to "+e))})}async function N(){$(document).DOMNodeAppear(function(t){$(t.target).find("button:has(i.fa-reply), button:has(i.fa-reply-all)").click()},"div.detailed-status__action-bar")}async function R(){function E(t){var e;return!t.startsWith("http")||(e=new URL(t),location.hostname==e.hostname)?[!1,(t=t.split("/")).pop()||t.pop()]:[!0,t]}async function e(e){$(e).is("div.detailed-status")&&$(e).closest("div.focusable").length&&(e=$(e).closest("div.focusable"));var t=function(t){if($(t).find("span.display-name__account").length)return $(t).find("span.display-name__account").first().text().trim()}($(e));if(!function(t,e){if(q.fediact_hidemuted){var i,a,n=[],o=($(t).siblings(".status__prepend").length&&(i=$(t).siblings(".status__prepend").first(),$(i).find("a").attr("href"))&&n.push($(i).find("a").attr("href").split("?")[0]),$(t).find("span.h-card").each(function(){n.push($(this).find("a").attr("href").split("?")[0])}),[]);for(a of n){var s,r=a.split("/"),r=(r=r.pop()||r.pop()).slice(1);a.startsWith("http")&&(s=new URL(a)).hostname!=M.exturi&&s.hostname!=location.hostname?o.push(r+"@"+s.hostname):o.push(r+"@"+M.exturi)}return o.some(t=>L(t))||L(e)?($(t).hide(),i&&$(i).hide(),1):void 0}}(e,t)){var i=function(t){if($(t).is(".detailed-status__wrapper"))return(e=window.location.href.split("?")[0].split("/")).pop()||e.pop();if($(t).attr("data-id"))return $(t).attr("data-id").split("-").slice(-1)[0];if($(t).closest("article[data-id], div[data-id]").length)return $(t).closest("article[data-id], div[data-id]").first().attr("data-id").split("-").slice(-1)[0];if($(t).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)").length){var e=$(t).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)").first();if($(e).attr("href")){t=$(e).attr("href");if(~t.indexOf("interact/"))return(e=t.split("?")[0].split("/")).pop()||e.pop()}}}($(e)),[a,n]=(a=$(e),$(a).find("a.status__relative-time").length?E($(a).find("a.status__relative-time").first().attr("href").split("?")[0]):$(a).find("a.detailed-status__datetime").length?E($(a).find("a.detailed-status__datetime").first().attr("href").split("?")[0]):$(a).find("a.modal-button").length?E($(a).find("a.modal-button").first().attr("href").split("?")[0]):[!1,void 0]),o=i||n;if(o){var s=[],r=X(o),c=$(e).find("button:has(i.fa-star)").first(),d=($(c).length||(c=$(e).find("a.icon-button:has(i.fa-star), a.detailed-status__link:has(i.fa-star)")),$("Resolving...").insertAfter($(c)),$(e).find("button:has(i.fa-retweet)").first()),l=($(d).length||(d=$(e).find("a.icon-button:has(i.fa-retweet), a.detailed-status__link:has(i.fa-retweet)")),$(e).find("button:has(i.fa-bookmark)").first()),u=$(e).find("button:has(i.fa-reply), button:has(i.fa-reply-all), a.icon-button:has(i.fa-reply), a.icon-button:has(i.fa-reply-all)").first(),f=$(e).find("div.poll button").first(),p=$(e).find("button:has(i.fa-ellipsis-h,i.fa-ellipsis-fw,i.fa-ellipsis-v)").first();async function h(t,e,i){if(q.fediact_autoaction){for(var a={choices:[]},n=$(i.currentTarget).closest("div.poll"),o=$(n).find("li"),s=0;sView the results on your home instance.

      "),r)&&(M.processed[r][10]=!0,M.processed[r][11]=!0),t}}async function m(t,e){if(!q.fediact_autoaction)return z("Auto-action disabled."),!0;a=e,i=!1,$(a.currentTarget).children("i.fa-retweet").length?i=$(a.currentTarget).children("i.fa-retweet").hasClass("fediactive")?"unboost":"boost":$(a.currentTarget).children("i.fa-star").length?i=$(a.currentTarget).hasClass("fediactive")?"unfavourite":"favourite":$(a.currentTarget).children("i.fa-bookmark").length?i=$(a.currentTarget).hasClass("fediactive")?"unbookmark":"bookmark":$(a.currentTarget).attr("href")&&(~$(a.currentTarget).attr("href").indexOf("type=reblog")?i=$(a.currentTarget).hasClass("fediactive")?"unboost":"boost":~$(a.currentTarget).attr("href").indexOf("type=favourite")&&(i=$(a.currentTarget).hasClass("fediactive")?"unfavourite":"favourite"));var i,a=i;if(a){if(await j(t,a,null))return r&&(M.processed[r][11]=!0),"boost"==a||"unboost"==a?(B($(e.currentTarget),[["color","!remove","rgb(140, 141, 255)"]],"fediactive"),B($(e.currentTarget).find("i"),[["transition-duration","!remove","0.9s"],["background-position","!remove","0px 100%"]],"fediactive"),r&&(M.processed[r][3]=!M.processed[r][3])):"favourite"==a||"unfavourite"==a?(B($(e.currentTarget),[["color","!remove","rgb(202, 143, 4)"]],"fediactive"),B($(e.currentTarget).find("i"),[["animation","spring-rotate-out 1s linear","spring-rotate-in 1s linear"]],"fediactive"),r&&(M.processed[r][4]=!M.processed[r][4])):(B($(e.currentTarget),[["color","!remove","rgb(255, 80, 80)"]],"fediactive"),r&&(M.processed[r][5]=!M.processed[r][5])),!0;z("Could not execute action on home instance.")}else z("Could not determine action.")}function g(t){$(e).find(".fediactunresolved").remove(),$(e).find(".fediactprocessing").remove(),t[1]?($(l).removeClass("disabled").removeAttr("disabled"),$(p).removeClass("disabled").removeAttr("disabled"),$(f).removeAttr("disabled"),t[4]&&!$(c).hasClass("fediactive")&&(B($(c),[["color","!remove","rgb(202, 143, 4)"]],"fediactive"),B($(c).find("i"),[["animation","spring-rotate-out 1s linear","spring-rotate-in 1s linear"]],"fediactive")),t[3]&&!$(d).find("i.fediactive").length&&(B($(d),[["color","!remove","rgb(140, 141, 255)"]],"fediactive"),B($(d).find("i"),[["transition-duration","!remove","0.9s"],["background-position","!remove","0px 100%"]],"fediactive")),t[5]&&!$(l).hasClass("fediactive")&&B($(l),[["color","!remove","rgb(255, 80, 80)"]],"fediactive"),t[10]&&($(f).hide(),$(f).closest("div.poll").find("ul").replaceWith("

      View the results on your home instance.

      "))):$("Unresolved").insertAfter($(c))}function v(n){var t=n[1].split("@"),e=t.pop()||t.pop();$(u).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation(),t.originalEvent.isTrusted&&U(n[7]+"?fedireply")}),$(p).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation(),t.originalEvent.isTrusted&&(t=[],F(n[1])?t.push(["unblock",n[6]]):t.push(["block",n[6]]),J(n[1])?t.push(["unmute",n[6]]):t.push(["mute",n[6]]),W(n[1])?t.push(["domainunblock",e]):t.push(["domainblock",e]),H(t))}),$([c,d,l,f]).each(function(){$(f).length&&$(f).get(0).isEqualNode($(this).get(0))&&(e=!0);var e,i,a=0;$(this).on("click",async function(t){t.preventDefault(),t.stopImmediatePropagation(),t.originalEvent.isTrusted&&(1==++a?i=setTimeout(async function(){(e&&!n[10]?h(n[9],n[7],t):await m(n[2],t))||z("Action failed."),a=0},350):(clearTimeout(i),(e?h(n[9],n[7],t):await m(n[2],t))?U(n[7]):z("Action failed."),a=0))}).on("dblclick",function(t){t.preventDefault(),t.stopImmediatePropagation()})})}if(r){var b=M.processed[r];g(b),b[1]&&v(b)}else{if(a&&s.push(n),t){var _,k,w,y=t.match(S),[T,x]=[!1,!1],A=(!y.groups.handledomain||~location.hostname.indexOf(y.groups.handledomain)||(T=!0),[i]);a||A.push(n);for(_ of A=A.filter((t,e)=>void 0!==t&&A.indexOf(t)==e))T?x||((k=await V(location.protocol+"//"+location.hostname+"/"+t+"/"+_))&&(x=!0,s.push(k),I.test(k)?(w=k.match(I)).groups.handle&&w.groups.tootid&&w.groups.domain&&s.push(w.groups.domain+"/@"+w.groups.handle+"/"+w.groups.tootid):S.test(k)&&(w=k.match(S)).groups.handle&&w.groups.tootid&&w.groups.domain&&s.push(w.groups.domain+"/users/"+w.groups.handle+"/statuses/"+w.groups.tootid)),s.push(location.protocol+"//"+location.hostname+"/"+t+"/"+_)):(s.push(location.protocol+"//"+location.hostname+"/users/"+y.groups.handle+"/statuses/"+_),s.push(location.protocol+"//"+location.hostname+"/@"+y.groups.handle+"/"+_))}if(s.length){var C,P,O,N,R,D=!1;for(C of s=s.filter((t,e)=>s.indexOf(t)==e))D||([P,O]=await Q(C),P&&(D=!0,N="https://"+q.fediact_homeinstance+"/@"+P[0]+"/"+P[1],R=[o,...P,N,!0,...O,!1]));D?(r=G(R),g(R),v(R)):(z("Failed to resolve: "+s),r=G([o,!1]),g([o,!1]))}else z("Could not identify a post URI for home resolving."),r=G([o,!1]),g([o,!1])}}else z("Could not get toot data.")}}$(document).DOMNodeAppear(async function(t){M.isProcessing.includes($(t.target).get(0))||(M.isProcessing.push($(t.target).get(0)),e($(t.target)))},"div.status, div.detailed-status"),$(document).find("div.status, div.detailed-status").each(function(){M.isProcessing.includes($(this).get(0))||(M.isProcessing.push($(this).get(0)),e($(this)))})}async function D(){async function e(a){var e,n,t,i,o,s,r="follow",c=$(a).siblings("button:has(i.fa-ellipsis-fw,i.fa-ellipsis-v,i.fa-ellipsis-h)");async function d(t){return q.fediact_autoaction?(t=await j(t,r,null),"follow"==r&&t?($(a).text("Unfollow"),r="unfollow",!0):"unfollow"==r&&t?($(a).text("Follow"),r="follow",!0):void 0):(z("Auto-action disabled."),!0)}if($(a).closest("div.account-card").length)e=$(a).closest("div.account-card").find("div.display-name > span").text().trim();else for(const l of u)if($(l).length){(e=$(l).text().trim()).split("@").length-1==1&&(e=e+"@"+M.exturi);break}e&&!M.processedFollow.includes(e)&&($("Resolving...  ").insertBefore($(a)),(n=await O(e))?(M.processedFollow.push(e),$(c).length&&$(c).removeClass("disabled").removeAttr("disabled"),t=e.split("@"),i=t.pop()||t.pop(),(await P([n[0]]))[0]&&($(a).text("Unfollow"),r="unfollow"),$(c).on("click",function(t){t.preventDefault(),t.stopImmediatePropagation(),t.originalEvent.isTrusted&&(t=[],F(e)?t.push(["unblock",n[0]]):t.push(["block",n[0]]),J(e)?t.push(["unmute",n[0]]):t.push(["mute",n[0]]),W(e)?t.push(["domainunblock",i]):t.push(["domainblock",i]),H(t))}),o=0,$(a).on("click",async function(t){var e,i;t.preventDefault(),t.stopImmediatePropagation(),t.originalEvent.isTrusted&&(1==++o?s=setTimeout(async function(){d(n[0]),o=0},350):(clearTimeout(s),await d(n[0])?(e=$(a).text(),i="https://"+q.fediact_homeinstance+"/@"+n[1],$(a).text("Redirecting..."),setTimeout(function(){U(i),$(a).text(e)},1e3)):z("Action failed."),o=0))}).on("dblclick",function(t){t.preventDefault(),t.stopImmediatePropagation()})):z("Could not resolve user home ID."),$(a).siblings(".fediactprocessing").remove())}var t=i.join(",");$(document).DOMNodeAppear(async function(t){M.isProcessing.includes($(t.target).get(0))||(M.isProcessing.push($(t.target).get(0)),e($(t.target)))},t),$(document).find(t).each(function(){M.isProcessing.includes($(this).get(0))||(M.isProcessing.push($(this).get(0)),e($(this)))})}function t(t){var e,i=[];for(e of t.split(/\r?\n/))(e=e.trim()).length&&(a.test(e)?i.push(e):z("Removed invalid domain "+e+" from blacklist/whitelist."));return[...new Set(i)]}function E(){if(null==q.fediact_homeinstance||!q.fediact_homeinstance)return z("Mastodon home instance is not set."),!1;if(!q.fediact_token)return z("No API token available. Are you logged in to your home instance? If yes, wait for 1-2 minutes and reload page."),!1;if(M.tokenheader={Authorization:"Bearer "+q.fediact_token},!a.test(q.fediact_homeinstance))return z("Instance setting is not a valid domain name."),!1;if("whitelist"==q.fediact_mode){if(M.whitelist=t(q.fediact_whitelist),M.whitelist.length<1)return z("Whitelist is empty or invalid."),!1}else M.blacklist=t(q.fediact_blacklist);return!0}async function K(){if(location.hostname==q.fediact_homeinstance&&(M.fedireply=x("fedireply"),!M.fedireply))return z("Current site is your home instance."),!1;if("whitelist"==q.fediact_mode){if($.inArray(location.hostname,M.whitelist)<0)return z("Current site is not in whitelist."),!1}else if(-1<$.inArray(location.hostname,M.blacklist))return z("Current site is in blacklist."),!1;var t=await g("GET",location.protocol+"//"+location.hostname+o,null,null);return!!t&&!(!(t=JSON.parse(t).uri)||(t.startsWith("http")?(t=new URL(t),M.exturi=t.hostname):M.exturi=t,Y()?!q.fediact_runifloggedin&&!M.fedireply&&await T()&&(z("Already logged in to this external instance."),1):(z("Could not start background process"),1)))}async function Y(){chrome.runtime.onMessage.addListener(async function(t,e,i){t.urlchanged&&(M.processed=[],M.processedFollow=[],M.isProcessing=[],await _()||location.reload()),t.updatedfedisettings&&location.reload()});try{return await chrome.runtime.sendMessage({running:!0}),!0}catch(t){z(t)}return!1}function _(){return new Promise(async function(e){try{q=await(browser||chrome).storage.local.get(y)}catch(t){z(t),e(!1)}q&&E()?e(!0):e(!1)})}async function Z(){await(browser||chrome).storage.local.set(q),await _()||location.reload()}async function tt(){await _()?await K()?(M.fedireply?N:(D(),R))():z("Will not process this site."):z("Could not load settings.")}tt(); \ No newline at end of file