add support for replying

tests
lartsch 2022-12-04 11:56:42 -05:00
rodzic 5b4711bb1f
commit 8084a57480
6 zmienionych plików z 44 dodań i 10 usunięć

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "FediFollow",
"version": "0.8.2",
"version": "0.8.3",
"description": "Simplifies interactions on other Mastodon instances than your own. Visit https://github.com/lartsch/FediFollow-Chrome for more.",
"manifest_version": 2,
"content_scripts": [

Wyświetl plik

@ -1,6 +1,6 @@
{
"name": "FediFollow",
"version": "0.8.2",
"version": "0.8.3",
"description": "Simplifies interactions on other Mastodon instances than your own. Visit https://github.com/lartsch/FediFollow-Chrome for more.",
"manifest_version": 3,
"content_scripts": [

Wyświetl plik

@ -35,7 +35,7 @@ const settingsDefaults = {
}
// fix for cross-browser storage api compatibility and other global vars
var browser, chrome, lasthomerequest;
var browser, chrome, lasthomerequest, fedireply;
var lastUrl = window.location.href;
@ -71,6 +71,19 @@ function log(text) {
jQuery.fn.onAppear = jQuery.fn.DOMNodeAppear;
})(jQuery);
// extract given url parameter value
var getUrlParameter = function getUrlParameter(sParam) {
var sPageURL = window.location.search.substring(1),
sURLVariables = sPageURL.split('&'), sParameterName, i;
for (i = 0; i < sURLVariables.length; i++) {
sParameterName = sURLVariables[i].split('=');
if (sParameterName[0] === sParam) {
return sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
}
}
return false;
};
// promisified xhr for api calls
async function makeRequest(method, url, extraheaders) {
// try to prevent error 429 too many request by delaying home instance requests
@ -503,6 +516,13 @@ function extractHandle(selectors) {
return false;
}
// process any toots found on supported sites
async function processReply() {
$(document).DOMNodeAppear(function(e) {
$(e.target).find("button:has(i.fa-reply").click()
}, "div.detailed-status__action-bar")
}
// process any toots found on supported sites
async function processToots() {
async function clickAction(searchstring, e) {
@ -635,6 +655,7 @@ async function processToots() {
var favButton = $(el).find("button:has(i.fa-star), a.icon-button:has(i.fa-star)")
var boostButton = $(el).find("button:has(i.fa-retweet), a.icon-button:has(i.fa-retweet)")
var bookmarkButton = $(el).find("button:has(i.fa-bookmark)")
var replyButton = $(el).find("button:has(i.fa-reply)")
$(bookmarkButton).removeClass("disabled").removeAttr("disabled")
if (resolveAndAction[2]) {
if (!$(favButton).hasClass("fediactive")) {
@ -652,6 +673,11 @@ async function processToots() {
}
}
// continue with click handling...
$(replyButton).on("click", function(e){
e.preventDefault();
e.stopImmediatePropagation();
redirectTo(resolveAndAction[0]+"?fedireply")
})
var clicks = 0;
var timer;
$([favButton, boostButton, bookmarkButton]).each(function() {
@ -974,8 +1000,11 @@ function checkSettings() {
async function checkSite() {
// is this site on our home instance?
if (location.hostname == settings.fedifollow_homeinstance) {
log("Current site is your home instance.");
return false;
fedireply = getUrlParameter("fedireply")
if (!fedireply) {
log("Current site is your home instance.");
return false;
}
}
// are we in whitelist mode?
if (settings.fedifollow_mode == "whitelist") {
@ -1015,9 +1044,13 @@ async function run() {
if (checkSettings()) {
// check site (if and which scripts should run)
if (await checkSite()) {
processFollow();
processToots();
urlChangeLoop();
if (fedireply) {
processReply()
} else {
processFollow();
processToots();
urlChangeLoop();
}
} else {
log("Will not process this site.")
}

2
src/inject.min.js vendored

File diff suppressed because one or more lines are too long

Wyświetl plik

@ -41,6 +41,7 @@
div.status,
div.detailed-status__wrapper,
div.detailed-status__action-bar,
article,
div.account__header button.logo-button,
div.public-account-header a.logo-button,

Wyświetl plik

@ -1 +1 @@
@-moz-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-webkit-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-ms-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-o-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@keyframes nodeInserted{from{opacity:1}to{opacity:1}}div.status,div.detailed-status__wrapper,article,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{-webkit-animation-name:nodeInserted !important;-webkit-animation-duration:.001s !important;-ms-animation-name:nodeInserted !important;-ms-animation-duration:.001s !important;-moz-animation-name:nodeInserted !important;-moz-animation-duration:.001s !important;-o-animation-name:nodeInserted !important;-o-animation-duration:.001s !important;animation-name:nodeInserted !important;animation-duration:.001s !important}
@-moz-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-webkit-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-ms-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@-o-keyframes nodeInserted{from{opacity:1}to{opacity:1}}@keyframes nodeInserted{from{opacity:1}to{opacity:1}}div.status,div.detailed-status__wrapper,div.detailed-status__action-bar,article,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{-webkit-animation-name:nodeInserted !important;-webkit-animation-duration:.001s !important;-ms-animation-name:nodeInserted !important;-ms-animation-duration:.001s !important;-moz-animation-name:nodeInserted !important;-moz-animation-duration:.001s !important;-o-animation-name:nodeInserted !important;-o-animation-duration:.001s !important;animation-name:nodeInserted !important;animation-duration:.001s !important}