`;
cell.prepend(container);
// Getting reference of the search bar and the search options
const searchBar = document.querySelector("#searchBar");
const searchOptions = document.querySelector("#searchOptions");
// Add event listener for search bar
searchBar.addEventListener("click", function (event) {
// Makes it so search options will not disappear first
event.stopPropagation();
// Toggles the display of search options when search bar is clicked
searchOptions.style.display = "block";
});
// Add event listener for search options so search options will not disappear when clicked on
searchOptions.addEventListener("click", function (event) {
event.stopPropagation();
});
// Add event listener to document (disappear when anything other than the search bar/options is clicked)
document.addEventListener("click", function () {
// Hides the search options when click is outside the search bar
if (searchOptions.style.display === "block") {
searchOptions.style.display = "none";
}
});
// Add event listener for the Esc key to hide search options
document.addEventListener("keydown", function (event) {
if (event.key === "Escape") { // Check if the pressed key is Escape
searchOptions.style.display = "none"; // Hide the search options
}
});
// Redirect to search on Enter key press
searchBar.addEventListener("keydown", function (ev) {
if (ev.code === "Enter") {
searchURL()
}
});
// Add functionality for search button
document.querySelector("#searchButton").addEventListener("click", searchURL);
if (specialSearchParametersJSON.showFriends) {
await retrievesFriendsLists();
// Retrieve reference to "searchAuthor" input
const searchAuthorInput = document.querySelector("#searchAuthor");
// Create friends list
const friendsClass = document.createElement("class")
friendsClass.id = "friends-lists-search"
// Create a new paragraph element
const friendTitle = document.createElement('p');
// Add content to paragraph
friendTitle.textContent = "Friends (" + FRIENDS_LIST.length + "):";
const friendsLists = document.createElement("ul");
if (FRIENDS_LIST.length === 0) {
const friendItem = document.createElement("li");
friendItem.textContent = "Go make some friends :)";
friendsLists.appendChild(friendItem);
}
// Browse the friends table and create a list item for each word
FRIENDS_LIST.forEach(friend => {
const friendItem = document.createElement("li");
friendItem.textContent = friend;
// Add a click event listener to each list item
friendItem.addEventListener("click", function () {
searchAuthorInput.value = friend;
});
friendsLists.appendChild(friendItem);
});
// When you click on search author input
searchAuthorInput.addEventListener("click", function (event) {
friendsClass.style.display = "block"; //Display list of friends
});
const parentElement = document.getElementById('searchOptions');
const children = Array.from(parentElement.children);
const selectedChildren = children.slice(0, children.length - 2);
// Add event listener to all first child of the special search bar (disappear you click on element on the special search bar who are not the friend list, the button or the input)
selectedChildren.forEach(option => {
option.addEventListener('click', function () {
friendsClass.style.display = "none"; //Hide the friend lists
});
});
// Add paragraph to specific class
friendsClass.appendChild(friendTitle);
friendsClass.appendChild(friendsLists);
searchOptions.appendChild(friendsClass); // Append the friend list by default
friendsClass.style.display = "none"; // Hide the friend list by default
document.addEventListener("click", function () {
// Hides the search options when click is outside the search bar
if (searchOptions.style.display === "block") {
friendsClass.style.display = "none"; //Hide the friend lists
}
});
}
}
}
specialSearch();
/*
Originally made by ucsanytaef
And adapted for cs.rin.ru enhanced by Altansar (nothing to adapt xD)
*/
function showAllSpoilers() {
if (options.show_all_spoilers) { //If show all spoilers is active
const spoilers = document.querySelectorAll('input[type="button"][value="Show"]');
spoilers.forEach(spoiler => {
spoiler.click();
});
}
}
showAllSpoilers();
function addLinkToQuote(message, id) {
const link = `${FORUM_BASE_URL}viewtopic.php?p=${id}#p${id}`;
const firstQuoteIndex = message.indexOf('[quote');
const firstQuoteEndIndex = message.indexOf(']', firstQuoteIndex) + 1;
if (firstQuoteIndex !== -1) {
const beforeQuote = message.slice(0, firstQuoteIndex);
const quoteTag = message.slice(firstQuoteIndex, firstQuoteEndIndex);
const afterQuote = message.slice(firstQuoteEndIndex);
message = `${beforeQuote}[url=${link}]${quoteTag}[/url]${afterQuote}`;
}
return message
}
function AddLinkQuote() {
if (options.add_link_quote) {
const id = new URLSearchParams(new URL(window.location.href).search).get('p');
const messageTextArea = document.querySelector('textarea[name="message"]');
if (messageTextArea) {
let message = messageTextArea.value;
message = addLinkToQuote(message, id)
messageTextArea.value = message
}
}
}
AddLinkQuote();
// Quick reply panel
if (options.quick_reply && quickReplyPanel) {
let button = document.createElement("button");
button.innerHTML = "Show Quick Reply Panel";
button.style.cssText = "position: fixed; bottom: 0%; left: 0%; min-height: 40px; min-width: 50px; width: 10%; height: 3%; z-index: 9999;";
button.addEventListener("click", function () {
if (quickReplyPanel.style.position !== "sticky") {
quickReplyPanel.style.position = "sticky";
quickReplyPanel.style.bottom = "0px";
button.innerHTML = "Hide Quick Reply Panel";
} else {
quickReplyPanel.style.position = "static";
button.innerHTML = "Show Quick Reply Panel";
}
});
document.body.appendChild(button);
}
function quotify() {
if (quickReplyPanel) {
$("a:has([title='Reply with quote'])").each(function () {
const quoteLink = this.href;
if (!quoteLink.includes("posting.php")) return;
this.href = "javascript:void(0)";
const postElem = $(this).parents().eq(7);
const postID = $(postElem).find("a[name]").last().attr("name").slice(1);
const author = $(postElem).find(".postauthor").text();
const authorID = $(postElem).find("[title=Profile]").parent().attr("href").split("u=")[1];
const child = $(this).find("[title='Reply with quote']");
$(this).find('[title="Reply with quote"]').on("click", function () {
console.log(postID);
console.log(quoteLink);
GM_xmlhttpRequest({
url: quoteLink,
onload: function (response) {
let postBody = $(response.responseText).find("[name=message]").text();
if (options.add_link_quote) {
postBody = addLinkToQuote(postBody, postID)
}
$("[name=message]")[0].value += postBody;
const quoted = $('