Update: Done! I have installed
certbot.
Thank you. But now I have another request.
![Cheesy](https://bitcointalk.org/Smileys/default/cheesy.gif)
I still can't make requests to your website from a browser because of
CORS.
Access to fetch at 'https://loyce.club/trust/latestversion.txt' from origin 'https://bitcointalk.org' has been blocked by
CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your
needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.
It's also a simple fix, but I'm not sure what do you use for your website. Other than that, I have already created a script (with a lot of copy pasting from BPIP's extension) that adds a button to your Trust List on everyone's profile/posts.
edit:
For now, I made so the requests go through my proxy server, which makes the request to your page, bypassing CORS. It also needs a cool icon. Right now, I'm using one I downloaded from google after searching for "trust favicon". Big credits to BPIP's extension and their coders, since I just took a big chunk of code from their extension.
The "latestversion" link is cached for 1 hour to avoid making a new request for every page refresh.
// ==UserScript==
// @name Loyce Trust List Viewer Button
// @version 0.1
// @description adds a button under each user's profile with the latest link to Loyce's Trust Viewer list.
// @author TryNinja
// @match https://bitcointalk.org/index.php?topic=*
// @match https://bitcointalk.org/index.php?action=profile;u=*
// @grant none
// @credits A big part of the code was taken (copy-pasted and modified) from BPIP's extension. https://bitcointalk.org/index.php?topic=5224821.0
// ==/UserScript==
(function() {
const MAX_VALID_USER_ID = 1500000000;
const PROFILE_URL_PREFIX = "https://bitcointalk.org/index.php?action=profile;u=";
const LOYCE_TRUST_LAST_VERSION_URL = "https://loyce.club/trust/latestversion.txt";
let LOYCE_TRUST_URL;
let LOYCE_TRUST_URL_PROFILE;
let LOYCE_TRUST_PROFILE_BUTTON_HTML;
function injectLoyceTrustButtons() {
LOYCE_TRUST_URL_PROFILE = LOYCE_TRUST_URL + "%%USERID%%.html";
LOYCE_TRUST_PROFILE_BUTTON_HTML = '
';
if (window.location.href.startsWith(PROFILE_URL_PREFIX)) {
const user_id = window.location.href.replace(PROFILE_URL_PREFIX, "");
const user_name_cell = document.querySelector("tr.titlebg ~ tr td.windowbg table tr").lastElementChild;
LOYCE_TRUST_PROFILE_BUTTON_HTML = LOYCE_TRUST_PROFILE_BUTTON_HTML.replace("%%USERID%%", user_id);
setTimeout(() => {
user_name_cell.innerHTML = user_name_cell.innerHTML + " " + LOYCE_TRUST_PROFILE_BUTTON_HTML;
}, 50)
} else {
document.querySelectorAll("img[title='View Profile']")
.forEach(img => {
let profile_box = img.parentElement.parentElement.parentElement;
let user_name_link = profile_box.querySelector("b > a");
let profile_link = profile_box.querySelector("div.smalltext a[href*='action=profile']");
if (user_name_link && profile_link) {
let user_id = user_name_link.getAttribute("href")
.replace(PROFILE_URL_PREFIX, "");
if (user_id > MAX_VALID_USER_ID) {
return;
}
const loyceTrustProfileFullURL = LOYCE_TRUST_URL_PROFILE.replace("%%USERID%%", user_id);
const loyceTrustButtonElement = document.createElement("a");
loyceTrustButtonElement.setAttribute('href', loyceTrustProfileFullURL);
loyceTrustButtonElement.setAttribute('target', '_blank');
const loyceTrustButtonImageElement = document.createElement("img");
loyceTrustButtonImageElement.setAttribute('src', 'https://i.imgur.com/2Gfqvto.png');
loyceTrustButtonImageElement.setAttribute('style', 'width: 16px; height: 16px;');
loyceTrustButtonImageElement.setAttribute('title', 'Loyce\'s Trust Viewer');
loyceTrustButtonElement.appendChild(loyceTrustButtonImageElement);
profile_link.before(loyceTrustButtonElement);
}
});
}
}
function getLatestLoyceTrustURL() {
let cached = JSON.parse(localStorage.getItem('@btt-ninja-cache/loyce-trust-link'));
if (!cached) {
fetch(LOYCE_TRUST_LAST_VERSION_URL)
.then((response) => response.text())
.then(data => {
LOYCE_TRUST_URL = data;
cached = {
last_url: data,
time: Date.now()
};
localStorage.setItem('@btt-ninja-cache/loyce-trust-link', JSON.stringify(cached));
injectLoyceTrustButtons();
});
} else {
LOYCE_TRUST_URL = cached.last_url;
const oneHourAgo = Date.now() - 1000 * 60 * 60;
if (cached.time < oneHourAgo) {
localStorage.setItem('@btt-ninja-cache/loyce-trust-link', null);
}
injectLoyceTrustButtons();
}
}
getLatestLoyceTrustURL();
})();