-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathof-enhancer.user.js
154 lines (139 loc) · 5.51 KB
/
of-enhancer.user.js
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// ==UserScript==
// @name Profile to XenForo Search
// @namespace https://github.com/n30liberal/random-userscripts/
// @version 4.0
// @description Add a button to search the profile URL on a XenForo forum
// @author ne0liberal
// @match https://onlyfans.com/*
// @match https://www.instagram.com/*
// @match https://twitter.com/*
// @match https://fansly.com/*
// @match https://www.tiktok.com/*
// @match https://www.reddit.com/*
// @updateURL https://github.com/ne0lith/random-userscripts/raw/main/of-enhancer.user.js
// @downloadURL https://github.com/ne0lith/random-userscripts/raw/main/of-enhancer.user.js
// ==/UserScript==
(function () {
'use strict';
const domainConfig = {
'onlyfans.com': {
colorScheme: {
background: '#00aff0',
color: '#feeff7',
},
profileRegex: /^https?:\/\/onlyfans\.com\/[a-zA-Z0-9_-]+$/,
enabled: true,
},
'fansly.com': {
colorScheme: {
background: '#2699F6',
color: '#ffffff',
},
profileRegex: /^https?:\/\/fansly\.com\/[a-zA-Z0-9_-]+\/posts$/,
enabled: true,
},
'twitter.com': {
colorScheme: {
background: '#1da1f2',
color: '#ffffff',
},
profileRegex: /^https?:\/\/twitter\.com\/(?!(home|settings|notifications|explore|messages)\/?$)([a-zA-Z0-9_]+)(?:\/(media|with_replies|highlights|likes))?\/?$/,
enabled: true,
},
'www.instagram.com': {
colorScheme: {
background: '#e4405f',
color: '#ffffff',
},
profileRegex: /^https?:\/\/www\.instagram\.com\/(?!(explore|)[a-zA-Z0-9_\.]+\/?$)/,
enabled: false,
},
'www.tiktok.com': {
colorScheme: {
background: '#69c9d0',
color: '#ffffff',
},
profileRegex: /https?:\/\/www\.tiktok\.com\/@/,
enabled: true,
},
'www.reddit.com': {
colorScheme: {
background: '#ff4500',
color: '#ffffff',
},
profileRegex: /^https?:\/\/www\.reddit\.com\/(?!(?:r\/(?:all|popular|mod)\/?$|[^/]*\/?$))(r\/[a-zA-Z0-9_]+|u(?:ser)?\/[a-zA-Z0-9_]+)\/?(?:\?.*)?$/,
enabled: true,
},
};
function isProfilePage() {
const domain = window.location.hostname;
if (domain in domainConfig) {
const profileRegex = domainConfig[domain].profileRegex;
return profileRegex.test(window.location.href) && domainConfig[domain].enabled;
}
return false;
}
function sanitizeQuery(query) {
query = query.replace(/https?:\/\/(?:www\.)?reddit\.com\/(r|u(?:ser)?|user)\/([a-zA-Z0-9_]+)\/?.*$/, 'https://www.reddit.com/$1/$2/');
query = query.replace(/(https?:\/\/(?:www\.)?tiktok\.com\/@)([a-zA-Z0-9_]+)(?:\/|(\?|$).*)?$/, '$1$2');
if (query.includes('twitter.com')) {
query = query.replace(/\/?(media|with_replies|highlights|likes)?\/?$/, '');
}
if (query.includes('fansly.com')) {
query = query.replace(/\/?posts$/, '');
}
return query;
}
function constructSearchURL(query) {
const cleanedQuery = sanitizeQuery(query);
const xenForoBaseURL = 'https://simpcity.su/search/';
const encodedQuery = encodeURIComponent(cleanedQuery);
return `${xenForoBaseURL}?q=${encodedQuery}&o=relevance`;
}
function addSearchButton() {
const existingButton = document.getElementById('xenforo-search-button');
if (existingButton) return;
const domain = window.location.hostname;
if (!(domain in domainConfig)) return;
const button = document.createElement('div');
button.id = 'xenforo-search-button';
button.textContent = 'Search';
button.style.position = 'fixed';
button.style.top = '10px';
button.style.left = '10px';
button.style.width = '75px';
button.style.height = '75px';
button.style.background = domainConfig[domain].colorScheme.background;
button.style.color = domainConfig[domain].colorScheme.color;
button.style.fontWeight = 'bold';
button.style.fontSize = '13px';
button.style.textAlign = 'center';
button.style.lineHeight = '75px';
button.style.cursor = 'pointer';
button.style.zIndex = '9999';
button.style.borderRadius = '25%';
button.addEventListener('click', function () {
const profileURL = window.location.href;
const searchURL = constructSearchURL(profileURL);
window.open(searchURL, '_blank');
});
document.body.appendChild(button);
}
function removeSearchButton() {
const existingButton = document.getElementById('xenforo-search-button');
if (existingButton) {
existingButton.remove();
}
}
const observer = new MutationObserver(function () {
if (isProfilePage()) {
addSearchButton();
} else {
removeSearchButton();
}
});
observer.observe(document.body, { childList: true, subtree: true });
if (isProfilePage()) {
addSearchButton();
}
})();