-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmart-follow
48 lines (45 loc) · 1.54 KB
/
smart-follow
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
javascript:
var cUL = 0;
var pUL = 0;
var fSL = 0;
var hostname = location.hostname;
var uL = 0;
var username = "";
var followURL = "";
try {
var columnUsername = document.getElementsByClassName("account__header__username")[0].innerHTML;
var cUL = columnUsername.match(/@/g || []).length;
} catch (err) {}
try {
var profileUsername = document.getElementsByClassName('public-account-header__tabs__name')[0].innerText;
var pUL = profileUsername.match(/@/g || []).length;
} catch (err) {}
try {
if (profileUsername == null) {var profileUsername = document.getElementsByClassName('name')[0].innerText;
var pUL = profileUsername.match(/@/g || []).length;
}
} catch (err) {}
try {
var fullSelection = window.getSelection().toString();
var fSL = fullSelection.match(/@/g || []).length;
} catch (err) {}
if (fSL) {
username = fullSelection;
username = username.trim();
if (!(username.match(/^@/))) {username='@'+username;}
username = username.match(/(@)(\S[^\n]+)/)[2];
} else if (cUL) {
username = columnUsername.match(/(@)(\S[^\n]+)/)[2];
} else if (pUL) {
username = profileUsername.match(/\n(@)(\S[^\n]+)/)[2];
}
username = username.trim();
hostname = hostname.trim();
if (username) {
if (username.match(/@/g)) {
followURL='https://example.mastodon.instance/authorize_follow?acct='+encodeURIComponent(username);
} else {
followURL='https://example.mastodon.instance/authorize_follow?acct='+encodeURIComponent(username+'@'+hostname);
}
void(window.open(followURL, '_blank','width=600,height=600,toolbar=no'));
}