yoohoo! hot sauce please
10:27, 7 September 2026 (UTC)
MediaWiki:Common.js: Difference between revisions
From 2swagg wiki
Jump to navigationJump to search
Make MonoBook the global default and remove navigation borders Tag: Reverted |
Build the youtube iframe on first click so autoplay actually works |
||
| (9 intermediate revisions by 2 users not shown) | |||
| Line 13: | Line 13: | ||
}); | }); | ||
/* | /* I LOVE STEALING CODE FROM SOYWIKI!!!! */ | ||
(function () { | |||
// Client side "<choose uncached>" replacement test | |||
mw.hook('wikipage.content').add(function ($content) { | |||
var | $content.find('.choose-uncached').each(function () { | ||
var $container = $(this); | |||
var $options = $container.find('.choose-option'); | |||
if ($options.length === 0) return; | |||
})(); | var index = Math.floor(Math.random() * $options.length); | ||
$options.eq(index).show(); | |||
}); | |||
}); | |||
// Gallery controls | |||
$(document).ready(function() { | |||
$(".gallerycontrols").each(function() { | |||
var $controls = $(this); | |||
var classes = $controls.attr("class").split(/\s+/); | |||
var secondClass = classes[1] || ""; | |||
var galleryKey = secondClass.replace(/^for-/, ""); | |||
if (!galleryKey) return; | |||
var $gallery = $(".gallery." + galleryKey); | |||
if (!$gallery.length) return; | |||
$controls.empty(); | |||
function applyTraditional() { | |||
$gallery | |||
.removeClass("mw-gallery-nolines") | |||
.addClass("mw-gallery-traditional"); | |||
$gallery.find(".thumb").css({ | |||
width: "150px", | |||
height: "150px" | |||
}); | |||
$gallery.find(".gallerybox").css({ | |||
width: "155px" | |||
}); | |||
} | |||
function applyNoLines() { | |||
$gallery | |||
.removeClass("mw-gallery-traditional") | |||
.addClass("mw-gallery-nolines"); | |||
$gallery.find(".thumb").css({ | |||
width: "120px", | |||
height: "120px" | |||
}); | |||
$gallery.find(".gallerybox").css({ | |||
width: "125px" | |||
}); | |||
} | |||
var $slider = $("<input>", { | |||
type: "range", | |||
min: 50, | |||
max: 200, | |||
value: 100 | |||
}).css("height", "10px"); | |||
var $percent = $("<span>100%</span>"); | |||
$slider.on("input", function() { | |||
var value = $(this).val(); | |||
$gallery.css("zoom", value / 100); | |||
$percent.text(value + "%"); | |||
}); | |||
var $lineBreak = $("<br>", { | |||
class: "mobilegallerycontrolsbr" | |||
}); | |||
var $borderCheckbox = $("<input>", { | |||
type: "checkbox", | |||
id: "toggle-borders-" + galleryKey | |||
}).prop("checked", true); | |||
var $borderLabel = $("<label>", { | |||
for: "toggle-borders-" + galleryKey, | |||
text: " Image borders" | |||
}); | |||
$borderCheckbox.on("change", function() { | |||
if ($(this).is(":checked")) { | |||
applyTraditional(); | |||
} else { | |||
applyNoLines(); | |||
} | |||
}); | |||
applyTraditional(); | |||
var $captionCheckbox = $("<input>", { | |||
type: "checkbox", | |||
id: "toggle-captions-" + galleryKey | |||
}).prop("checked", true); | |||
var $captionLabel = $("<label>", { | |||
for: "toggle-captions-" + galleryKey, | |||
text: " Image captions" | |||
}); | |||
$captionCheckbox.on("change", function() { | |||
if ($(this).is(":checked")) { | |||
$gallery.find(".gallerytext").show(); | |||
} else { | |||
$gallery.find(".gallerytext").hide(); | |||
} | |||
}); | |||
$controls.append( | |||
$slider, | |||
" ", | |||
$percent, | |||
" ", | |||
$lineBreak, | |||
$borderCheckbox, | |||
$borderLabel, | |||
" ", | |||
$captionCheckbox, | |||
$captionLabel | |||
); | |||
}); | |||
}); | |||
// Pulls the user's block reason from the block log and inserts it into the Permablocked template | |||
mw.loader.using('mediawiki.api').then(() => { | |||
$(function () { | |||
const blockspan = document.querySelector('#blockreason'); | |||
if (!blockspan) return; | |||
const username = blockspan.dataset.username; | |||
if (!username) return; | |||
const api = new mw.Api(); | |||
api.get({ | |||
action: 'query', | |||
list: 'logevents', | |||
letype: 'block', | |||
letitle: 'User:' + username, | |||
lelimit: 1 | |||
}).then(data => { | |||
let log = null; | |||
if ( | |||
data && | |||
data.query && | |||
data.query.logevents && | |||
data.query.logevents.length | |||
) { | |||
log = data.query.logevents[0]; | |||
} | |||
if (!log) { | |||
blockspan.textContent = 'User isn\'t blocked.'; | |||
return; | |||
} | |||
blockspan.textContent = log.comment || 'No reason.'; | |||
}).catch(err => { | |||
console.error(err); | |||
blockspan.textContent = 'Error'; | |||
}); | |||
}); | |||
}); | |||
/* Below is stolen from ED at User:Cobblestone's request */ | |||
/* Collapsible toggle */ | |||
$(document).ready(function() { | |||
$(".collapsibletoggletext").click(function() { | |||
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext"); | |||
}); | |||
}); | |||
/* Cycle forwards or backwards through elements one at a time via click */ | |||
$(function(){ | |||
$(".cyclesequence").find(".cyclesequencelinknext").click(function(){ | |||
if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").length === 0) { | |||
$(this).closest(".cyclesequence").find(".cyclesequenceitem:first").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); | |||
} | |||
else { | |||
$(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); | |||
} | |||
}); | |||
$(".cyclesequence").find(".cyclesequencelinkprev").click(function(){ | |||
if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").length === 0) { | |||
$(this).closest(".cyclesequence").find(".cyclesequenceitem:last").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); | |||
} | |||
else { | |||
$(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext"); | |||
} | |||
}); | |||
}); | |||
/* Click link to show one or more items and hide other items */ | |||
$(function() { | |||
$(".morphlink").click(function() { | |||
var correspondingContent = $(this).data("correspondingcontent"); | |||
if ($(this).parents(".morphcontainer").length) { | |||
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext"); | |||
if ($("#" + correspondingContent).length) // morphing object uses IDs | |||
$("#" + correspondingContent).removeClass("hiddentext"); | |||
else // morphing object uses classes | |||
$("." + correspondingContent).removeClass("hiddentext"); | |||
} | |||
else { | |||
if ($("#" + correspondingContent).length) { // morphing object uses IDs | |||
$("#" + correspondingContent).removeClass("hiddentext"); | |||
$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); | |||
} | |||
else { // morphing object uses classes | |||
$("." + correspondingContent).removeClass("hiddentext"); | |||
$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); | |||
} | |||
} | |||
}); | |||
}); | |||
$(".morphlink").click(function() { | |||
var correspondingContent = $(this).data("correspondingcontent"); | |||
// the lines to add, add these 2 | |||
$(this).siblings(".morphlink").removeClass("active"); | |||
$(this).addClass("active"); | |||
//end | |||
if ($(this).parents(".morphcontainer").length) { | |||
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext"); | |||
if ($("#" + correspondingContent).length) | |||
$("#" + correspondingContent).removeClass("hiddentext"); | |||
else | |||
$("." + correspondingContent).removeClass("hiddentext"); | |||
} | |||
else { | |||
if ($("#" + correspondingContent).length) { | |||
$("#" + correspondingContent).removeClass("hiddentext"); | |||
$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); | |||
} | |||
else { | |||
$("." + correspondingContent).removeClass("hiddentext"); | |||
$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext"); | |||
} | |||
} | |||
}); | |||
$(document).ready(function() { | |||
$(".collapsibletoggletext").click(function() { | |||
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext"); | |||
}); | |||
//add this one too, this one sets the default active tab on page load | |||
$(".morphcontainer").each(function() { | |||
$(this).find(".morphlink").first().addClass("active"); | |||
}); | |||
}); | |||
//SHOWING JANNY INTERFACE FOR JANNIES | |||
//shamelessly ripping this from wikipedia's guide - Manual:Interface/Sidebar | |||
function ModifySidebar( action, section, name, link ) { | |||
try { | |||
switch ( section ) { | |||
case 'languages': | |||
var target = 'p-lang'; | |||
break; | |||
case 'toolbox': | |||
var target = 'p-tb'; | |||
break; | |||
case 'navigation': | |||
var target = 'p-navigation'; | |||
break; | |||
default: | |||
var target = 'p-' + section; | |||
break; | |||
} | |||
if ( action == 'add' ) { | |||
var node = document.getElementById( target ) | |||
.getElementsByTagName( 'div' )[0] | |||
.getElementsByTagName( 'ul' )[0]; | |||
var aNode = document.createElement( 'a' ); | |||
var liNode = document.createElement( 'li' ); | |||
aNode.appendChild( document.createTextNode( name ) ); | |||
aNode.setAttribute( 'href', link ); | |||
liNode.appendChild( aNode ); | |||
liNode.className = 'plainlinks'; | |||
node.appendChild( liNode ); | |||
} | |||
if ( action == 'remove' ) { | |||
var list = document.getElementById( target ) | |||
.getElementsByTagName( 'div' )[0] | |||
.getElementsByTagName( 'ul' )[0]; | |||
var listelements = list.getElementsByTagName( 'li' ); | |||
for ( var i = 0; i < listelements.length; i++ ) { | |||
if ( | |||
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name || | |||
listelements[i].getElementsByTagName( 'a' )[0].href == link | |||
) | |||
{ | |||
list.removeChild( listelements[i] ); | |||
} | |||
} | |||
} | |||
} catch( e ) { | |||
// let's just ignore what's happened | |||
return; | |||
} | |||
} | |||
// adjustments | |||
function CustomizeModificationsOfSidebar() { | |||
window.popupAdminLinks = true; | |||
// Since everybody is going to read this, the goal is to add Janny Interface for jannies | |||
ModifySidebar( 'add', 'janny', 'Interface', 'https://wiki.2swagg.net/index.php/2swagg_wiki:Interface' ); | |||
ModifySidebar( 'add', 'janny', 'Jannycord', 'https://discord.gg/vN8DMAWYDk' ); | |||
} //'navigation' doesn't work due to capitalization but 'toolbox' does | |||
const groups = mw.config.get( 'wgUserGroups', [] ); | |||
if ( | |||
groups.includes( 'Helper' ) || | |||
groups.includes( 'approver' ) || | |||
groups.includes( 'administrator' ) || | |||
groups.includes( 'bureaucrat' ) | |||
) { | |||
jQuery( CustomizeModificationsOfSidebar ); | |||
} | |||
// ===== User:MANVS page sparkle cursor trail, scoped to just that page ===== | |||
if ( document.body.classList.contains( 'page-User_MANVS' ) ) { | |||
( function () { | |||
var chars = [ '✨', '⭐', '⋆' ]; | |||
var lastTime = 0; | |||
document.addEventListener( 'mousemove', function ( e ) { | |||
var now = Date.now(); | |||
if ( now - lastTime < 55 ) { | |||
return; | |||
} | |||
lastTime = now; | |||
var el = document.createElement( 'span' ); | |||
el.className = 'manvs-sparkle'; | |||
el.textContent = chars[ Math.floor( Math.random() * chars.length ) ]; | |||
el.style.left = e.clientX + 'px'; | |||
el.style.top = e.clientY + 'px'; | |||
document.body.appendChild( el ); | |||
setTimeout( function () { | |||
el.remove(); | |||
}, 900 ); | |||
} ); | |||
} )(); | |||
} | |||
// ===== User:MANVS page now-playing widget: starts on first click anywhere ===== | |||
if ( document.body.classList.contains( 'page-User_MANVS' ) ) { | |||
document.addEventListener( 'click', function startNowPlaying() { | |||
document.removeEventListener( 'click', startNowPlaying ); | |||
var slot = document.getElementById( 'manvs-nowplaying-embed' ); | |||
if ( !slot ) { | |||
return; | |||
} | |||
var iframe = document.createElement( 'iframe' ); | |||
iframe.width = '200'; | |||
iframe.height = '113'; | |||
iframe.src = 'https://www.youtube-nocookie.com/embed/67_ZX_1yv4w?autoplay=1&enablejsapi=1'; | |||
iframe.setAttribute( 'allow', 'autoplay; encrypted-media' ); | |||
iframe.setAttribute( 'frameborder', '0' ); | |||
iframe.setAttribute( 'allowfullscreen', '' ); | |||
slot.appendChild( iframe ); | |||
var hint = document.querySelector( '.manvs-nowplaying-hint' ); | |||
if ( hint ) { | |||
hint.remove(); | |||
} | |||
} ); | |||
} | |||
Latest revision as of 01:58, 18 September 2026
/* Multiquote cycle controls */
$(function(){
$(".cyclesequence").find(".cyclesequencelinknext").on("click", function(){
var box=$(this).closest(".cyclesequence"), current=box.find(".cyclesequenceitem:visible");
(current.next(".cyclesequenceitem").length ? current.next(".cyclesequenceitem") : box.find(".cyclesequenceitem:first")).removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
});
$(".cyclesequence").find(".cyclesequencelinkprev").on("click", function(){
var box=$(this).closest(".cyclesequence"), current=box.find(".cyclesequenceitem:visible");
(current.prev(".cyclesequenceitem").length ? current.prev(".cyclesequenceitem") : box.find(".cyclesequenceitem:last")).removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
});
});
/* I LOVE STEALING CODE FROM SOYWIKI!!!! */
// Client side "<choose uncached>" replacement test
mw.hook('wikipage.content').add(function ($content) {
$content.find('.choose-uncached').each(function () {
var $container = $(this);
var $options = $container.find('.choose-option');
if ($options.length === 0) return;
var index = Math.floor(Math.random() * $options.length);
$options.eq(index).show();
});
});
// Gallery controls
$(document).ready(function() {
$(".gallerycontrols").each(function() {
var $controls = $(this);
var classes = $controls.attr("class").split(/\s+/);
var secondClass = classes[1] || "";
var galleryKey = secondClass.replace(/^for-/, "");
if (!galleryKey) return;
var $gallery = $(".gallery." + galleryKey);
if (!$gallery.length) return;
$controls.empty();
function applyTraditional() {
$gallery
.removeClass("mw-gallery-nolines")
.addClass("mw-gallery-traditional");
$gallery.find(".thumb").css({
width: "150px",
height: "150px"
});
$gallery.find(".gallerybox").css({
width: "155px"
});
}
function applyNoLines() {
$gallery
.removeClass("mw-gallery-traditional")
.addClass("mw-gallery-nolines");
$gallery.find(".thumb").css({
width: "120px",
height: "120px"
});
$gallery.find(".gallerybox").css({
width: "125px"
});
}
var $slider = $("<input>", {
type: "range",
min: 50,
max: 200,
value: 100
}).css("height", "10px");
var $percent = $("<span>100%</span>");
$slider.on("input", function() {
var value = $(this).val();
$gallery.css("zoom", value / 100);
$percent.text(value + "%");
});
var $lineBreak = $("<br>", {
class: "mobilegallerycontrolsbr"
});
var $borderCheckbox = $("<input>", {
type: "checkbox",
id: "toggle-borders-" + galleryKey
}).prop("checked", true);
var $borderLabel = $("<label>", {
for: "toggle-borders-" + galleryKey,
text: " Image borders"
});
$borderCheckbox.on("change", function() {
if ($(this).is(":checked")) {
applyTraditional();
} else {
applyNoLines();
}
});
applyTraditional();
var $captionCheckbox = $("<input>", {
type: "checkbox",
id: "toggle-captions-" + galleryKey
}).prop("checked", true);
var $captionLabel = $("<label>", {
for: "toggle-captions-" + galleryKey,
text: " Image captions"
});
$captionCheckbox.on("change", function() {
if ($(this).is(":checked")) {
$gallery.find(".gallerytext").show();
} else {
$gallery.find(".gallerytext").hide();
}
});
$controls.append(
$slider,
" ",
$percent,
" ",
$lineBreak,
$borderCheckbox,
$borderLabel,
" ",
$captionCheckbox,
$captionLabel
);
});
});
// Pulls the user's block reason from the block log and inserts it into the Permablocked template
mw.loader.using('mediawiki.api').then(() => {
$(function () {
const blockspan = document.querySelector('#blockreason');
if (!blockspan) return;
const username = blockspan.dataset.username;
if (!username) return;
const api = new mw.Api();
api.get({
action: 'query',
list: 'logevents',
letype: 'block',
letitle: 'User:' + username,
lelimit: 1
}).then(data => {
let log = null;
if (
data &&
data.query &&
data.query.logevents &&
data.query.logevents.length
) {
log = data.query.logevents[0];
}
if (!log) {
blockspan.textContent = 'User isn\'t blocked.';
return;
}
blockspan.textContent = log.comment || 'No reason.';
}).catch(err => {
console.error(err);
blockspan.textContent = 'Error';
});
});
});
/* Below is stolen from ED at User:Cobblestone's request */
/* Collapsible toggle */
$(document).ready(function() {
$(".collapsibletoggletext").click(function() {
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext");
});
});
/* Cycle forwards or backwards through elements one at a time via click */
$(function(){
$(".cyclesequence").find(".cyclesequencelinknext").click(function(){
if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").length === 0) {
$(this).closest(".cyclesequence").find(".cyclesequenceitem:first").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
}
else {
$(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").next(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
}
});
$(".cyclesequence").find(".cyclesequencelinkprev").click(function(){
if ($(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").length === 0) {
$(this).closest(".cyclesequence").find(".cyclesequenceitem:last").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
}
else {
$(this).closest(".cyclesequence").find(".cyclesequenceitem:visible").prev(".cyclesequenceitem").removeClass("hiddentext").siblings(".cyclesequenceitem").addClass("hiddentext");
}
});
});
/* Click link to show one or more items and hide other items */
$(function() {
$(".morphlink").click(function() {
var correspondingContent = $(this).data("correspondingcontent");
if ($(this).parents(".morphcontainer").length) {
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext");
if ($("#" + correspondingContent).length) // morphing object uses IDs
$("#" + correspondingContent).removeClass("hiddentext");
else // morphing object uses classes
$("." + correspondingContent).removeClass("hiddentext");
}
else {
if ($("#" + correspondingContent).length) { // morphing object uses IDs
$("#" + correspondingContent).removeClass("hiddentext");
$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
}
else { // morphing object uses classes
$("." + correspondingContent).removeClass("hiddentext");
$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
}
}
});
});
$(".morphlink").click(function() {
var correspondingContent = $(this).data("correspondingcontent");
// the lines to add, add these 2
$(this).siblings(".morphlink").removeClass("active");
$(this).addClass("active");
//end
if ($(this).parents(".morphcontainer").length) {
$(this).parents(".morphcontainer").find(".morphcontent").addClass("hiddentext");
if ($("#" + correspondingContent).length)
$("#" + correspondingContent).removeClass("hiddentext");
else
$("." + correspondingContent).removeClass("hiddentext");
}
else {
if ($("#" + correspondingContent).length) {
$("#" + correspondingContent).removeClass("hiddentext");
$("#" + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
}
else {
$("." + correspondingContent).removeClass("hiddentext");
$("." + correspondingContent).siblings().filter($(".morphcontent")).addClass("hiddentext");
}
}
});
$(document).ready(function() {
$(".collapsibletoggletext").click(function() {
$(this).parent().children(".collapsibletoggletext").toggleClass("hiddentext");
});
//add this one too, this one sets the default active tab on page load
$(".morphcontainer").each(function() {
$(this).find(".morphlink").first().addClass("active");
});
});
//SHOWING JANNY INTERFACE FOR JANNIES
//shamelessly ripping this from wikipedia's guide - Manual:Interface/Sidebar
function ModifySidebar( action, section, name, link ) {
try {
switch ( section ) {
case 'languages':
var target = 'p-lang';
break;
case 'toolbox':
var target = 'p-tb';
break;
case 'navigation':
var target = 'p-navigation';
break;
default:
var target = 'p-' + section;
break;
}
if ( action == 'add' ) {
var node = document.getElementById( target )
.getElementsByTagName( 'div' )[0]
.getElementsByTagName( 'ul' )[0];
var aNode = document.createElement( 'a' );
var liNode = document.createElement( 'li' );
aNode.appendChild( document.createTextNode( name ) );
aNode.setAttribute( 'href', link );
liNode.appendChild( aNode );
liNode.className = 'plainlinks';
node.appendChild( liNode );
}
if ( action == 'remove' ) {
var list = document.getElementById( target )
.getElementsByTagName( 'div' )[0]
.getElementsByTagName( 'ul' )[0];
var listelements = list.getElementsByTagName( 'li' );
for ( var i = 0; i < listelements.length; i++ ) {
if (
listelements[i].getElementsByTagName( 'a' )[0].innerHTML == name ||
listelements[i].getElementsByTagName( 'a' )[0].href == link
)
{
list.removeChild( listelements[i] );
}
}
}
} catch( e ) {
// let's just ignore what's happened
return;
}
}
// adjustments
function CustomizeModificationsOfSidebar() {
window.popupAdminLinks = true;
// Since everybody is going to read this, the goal is to add Janny Interface for jannies
ModifySidebar( 'add', 'janny', 'Interface', 'https://wiki.2swagg.net/index.php/2swagg_wiki:Interface' );
ModifySidebar( 'add', 'janny', 'Jannycord', 'https://discord.gg/vN8DMAWYDk' );
} //'navigation' doesn't work due to capitalization but 'toolbox' does
const groups = mw.config.get( 'wgUserGroups', [] );
if (
groups.includes( 'Helper' ) ||
groups.includes( 'approver' ) ||
groups.includes( 'administrator' ) ||
groups.includes( 'bureaucrat' )
) {
jQuery( CustomizeModificationsOfSidebar );
}
// ===== User:MANVS page sparkle cursor trail, scoped to just that page =====
if ( document.body.classList.contains( 'page-User_MANVS' ) ) {
( function () {
var chars = [ '✨', '⭐', '⋆' ];
var lastTime = 0;
document.addEventListener( 'mousemove', function ( e ) {
var now = Date.now();
if ( now - lastTime < 55 ) {
return;
}
lastTime = now;
var el = document.createElement( 'span' );
el.className = 'manvs-sparkle';
el.textContent = chars[ Math.floor( Math.random() * chars.length ) ];
el.style.left = e.clientX + 'px';
el.style.top = e.clientY + 'px';
document.body.appendChild( el );
setTimeout( function () {
el.remove();
}, 900 );
} );
} )();
}
// ===== User:MANVS page now-playing widget: starts on first click anywhere =====
if ( document.body.classList.contains( 'page-User_MANVS' ) ) {
document.addEventListener( 'click', function startNowPlaying() {
document.removeEventListener( 'click', startNowPlaying );
var slot = document.getElementById( 'manvs-nowplaying-embed' );
if ( !slot ) {
return;
}
var iframe = document.createElement( 'iframe' );
iframe.width = '200';
iframe.height = '113';
iframe.src = 'https://www.youtube-nocookie.com/embed/67_ZX_1yv4w?autoplay=1&enablejsapi=1';
iframe.setAttribute( 'allow', 'autoplay; encrypted-media' );
iframe.setAttribute( 'frameborder', '0' );
iframe.setAttribute( 'allowfullscreen', '' );
slot.appendChild( iframe );
var hint = document.querySelector( '.manvs-nowplaying-hint' );
if ( hint ) {
hint.remove();
}
} );
}