// ==UserScript==
// @grant none
// ==/UserScript==
// Create a new <script> element and append it to the <head> element to load jQuery
// Define an array of content to use for each cloned element
var bankContent = [
'<div id="tooltip" class="with-margin" style="display: flex; width: 365px; height: 260px;" data-position="top"><div class="content"><div class="images"><div class="title">Populaires</div></div></div></div>',
'Bank 2 content',
'Bank 3 content',
'Bank 4 content',
'Bank 5 content'
];
// Find the first element with class "item onche"
var $original = $('.item.onche').eq(0);
// Clone the original element 5 times and change the hue-rotate filter for each clone
for (var i = 5; i > 0; i--) {
var $clone = $original.clone()
.addClass('bank_' + i)
.removeAttr('data-show-smileys')
.insertAfter($original)
.css('filter', 'hue-rotate(' + 180 + i * 22.5 + 'deg)');
// Add a click event listener to the clone & append the content element to the <body> element
$clone.on('click', function() {
var position = $(this).offset();
var $tooltip = $(bankContent[parseInt($(this).attr('class').slice(-1)) - 1])
.addClass('tooltip')
.css({left: position.left - 100 + 'px',top:
position.top - 265 + 'px'})
.appendTo('body')
});
}
// Add a click event listener to the document to hide the tooltip when clicking outside of ".item.onche" elements
$(document).on('click', function(event) {
$('.with-margin.tooltip').css('display','none')
}
});