User:Ca/RSNsearch.js
Appearance
< User:Ca
Code that you insert on this page could contain malicious content capable of compromising your account. If you import a script from another page with "importScript", "mw.loader.load", "iusc", or "lusc", take note that this causes you to dynamically load a remote script, which could be changed by others. Editors are responsible for all edits and actions they perform, including by scripts. User scripts are not centrally supported and may malfunction or become inoperable due to software changes. A guide to help you find broken scripts is available. If you are unsure whether code you are adding to this page is safe, you can ask at the appropriate village pump.
This code will be executed when previewing this page.
This code will be executed when previewing this page.
Documentation for this user script can be added at User:Ca/RSNsearch.
//written by ChatGPT
function openRSNSearchBox() {
$('body').prepend('<div id="rsn-modal">' +
'<div id="rsn-content">' +
'<h2>RSN Search</h2>' +
'<p>Search for topics on the Reliable Sources Noticeboard</p>' +
'<input type="text" id="rsn-input" placeholder="Enter search query">' +
'<a id="rsn-link" href="#" target="_blank">Search</a>' +
'<button id="rsn-close">✖</button>' +
'</div>' +
'</div>');
$("#rsn-modal").css({
"position": "fixed",
"z-index": "1",
"left": "0",
"top": "0",
"width": "100%",
"height": "100%",
"overflow": "hidden",
"background-color": "rgba(0, 0, 0, 0.4)"
});
$("#rsn-content").css({
"background-color": "#ffffff",
"margin": "15% auto",
"padding": "20px",
"border": "1px solid #ccc",
"width": "400px",
"font-size": "16px",
"box-shadow": "0px 2px 8px rgba(0, 0, 0, 0.2)",
"border-radius": "4px",
"text-align": "center",
"position": "relative" // Added relative position for #rsn-content
});
$("#rsn-close").css({
"position": "absolute", // Absolute positioning inside #rsn-content
"top": "10px",
"right": "10px",
"border": "none",
"background-color": "transparent",
"font-size": "24px",
"cursor": "pointer",
"outline": "none"
});
$("#rsn-close").click(function() {
$("#rsn-modal").remove();
});
$("#rsn-input").on("input", function() {
var inputValue = $(this).val();
var searchLink = "https://en.wikipedia.org/w/index.php?search=" + inputValue + "&prefix=Wikipedia%3AReliable+sources%2FNoticeboard&title=Special:Search&profile=advanced&fulltext=1&ns0=1";
$("#rsn-link").attr("href", searchLink);
});
}
$(document).ready(function() {
mw.util.addPortletLink('p-tb', 'javascript:void(0)', 'RSN Search', 'rsn-search-link', null, null);
$('#rsn-search-link').on('click', function() {
openRSNSearchBox();
});
});
