');
// replace original with modifyed html
$(this).replaceWith(enUserhtml[0] + newHtml + enUserhtml[1]);
});
} // END enabled
}
// show popup user info while click on avatar ... ==============
function EnstylerAvatarPopup() {
// code used for MyDealz avatar popup, thanks to mydealz :-)
var enPopupUser = ['',
];
// remove second image from cardview
if (GM_config.get('enConfUser')) { addStyleString('.thread-footer-cell a img.avatar.vAlign--all-m.space--mr-1.thread-avatar {display: none;}'); }
// replace every avatar link without popup
if (GM_config.get('enConfUser')) {
$('.thread-footer-cell a.user.linkPlain, .user.linkPlain.thread-user').each(function () {
var Iam = $(this);
// get inner html and link to user profile
var myHtml = Iam.html();
var mysrc = Iam.attr('href');
// seperate user name from image and add class user
var myAvatar1 = myHtml.replace(//,'');
// show small / medium sized Avatar
myAvatar1 = myAvatar1.replace('avatar--type-s','avatar--type-m'); //in Dealz
if (GM_config.get('enConfAvatar')) { myAvatar1 = myAvatar1.replace('thread-avatar','avatar--type-m'); }
// compose popup
var myPopup = enPopupUser[0] + Iam.attr('href') + enPopupUser[1] + myAvatar1 + enPopupUser[2] + ''+ myAvatar2 + '';
Iam.replaceWith(myPopup);
});
}
}
// ============= GM_config functions =======================================
// define GM_config elements
var fieldDefs = {
// Part one: load external content --------
'enstyler': {
'section': ['additonal features for Enstyler', ''],
'label': 'Install / Update CSS...', // Appears on the button
'type': 'button', // Makes this setting a button input
'click': function() { // Function to call when button is clicked
showUrl('https://userstyles.org/styles/128262#style-info'); }
},
'dontCookies': {
'label': 'Mozilla no cookies...', // Appears on the button
'type': 'button', // Makes this setting a button input
'click': function() { // Function to call when button is clicked
showUrl('https://addons.mozilla.org/de/addon/i-dont-care-about-cookies/'); }
},
//* thhis has to be the last one,display only if internal version is disabled
'externalMobileRedirect': {
'label': 'Amazon mobile redirect...', // Appears on the button
'type': 'button', // Makes this setting a button input
'click': function() { // Function to call when button is clicked
showUrl('https://greasyfork.org/de/scripts/19700'); }
}, // */
// part two: EnstylerJS internal configuration options ------
'hidden1': { // display next section, dont kow why ...
'section': ['Configuration', ''],
'type': 'hidden', // Makes this setting a hidden input
'value': 'Some hidden value' // Value stored
},
// postion of enstyler "button"
'enConfBtn': {
'label': 'Show Enstyler in MainNav', // Appears next to field
'type': 'checkbox', // Makes this setting a checkbox input
'default': false // Default value if user doesn't change it
},
'enConfBtnMinWidth': {
'label': 'only if width is bigger than ', // Appears next to field
'type': 'int', // Makes this setting a text input
'min': 600, // Optional lower range limit
'max': 1200, // Optional upper range limit
'size': 4, // Limit length of input (default is 25)
'default': 850 // Default value if user doesn't change it
},
// ehanced USerInfo
'enConfUser': {
'label': 'Show Popuop Userinfo', // Appears next to field
'type': 'checkbox', // Makes this setting a checkbox input
'default': true // Default value if user doesn't change it
},
'enConfAvatar': {
'label': 'bigger Avatar for Popuop', // Appears next to field
'type': 'checkbox', // Makes this setting a checkbox input
'default': true // Default value if user doesn't change it
},
// enable filtering of external links
'enConfFilterLink': {
'label': 'Amazon mobile redirect', // Appears next to field
'type': 'checkbox', // Makes this setting a checkbox input
'default': true // Default value if user doesn't change it
}, // */
// more Deal actions
'enConfMoreDeal': {
'label': 'additional Deal actions', // Appears next to field
'type': 'checkbox', // Makes this setting a checkbox input
'default': true // Default value if user doesn't change it
},
// display copy message at end of section ...
'copy': {
'section': ['', '(c) Gnadelwartz - Enstyler2 - Style your MyDealz'],
'type': 'hidden', // Makes this setting a hidden input
'value': 'Some hidden value' // Value stored
},
};
// display GM_copnfig as div, so we cam apply CSS!!
var enGMOptChange = false;
var enGMFrame = document.createElement('div');
document.body.appendChild(enGMFrame);
GM_config.init(
{
id: 'GM_config',
title: 'EnstylerJS - Settings',
fields: fieldDefs,
'events': // Callback functions object
{
//'init': function() { alert('onInit()'); },
// do not diplay external mobile redirect is internal is activated
'open': function() {
if (GM_config.get('enConfFilterLink')) {
GM_config.fields['externalMobileRedirect'].remove();
}
if (!GM_config.get('enConfBtn')) {
GM_config.fields['enConfBtnMinWidth'].remove();
}
if (!GM_config.get('enConfUser')) {
GM_config.fields['enConfAvatar'].remove();
}
},
//'reset': function() { enGMOptChange = true; },
// relaod page on close after save
'save': function() {
enGMOptChange = true;
if (GM_config.get('enConfFilterLink')) {
GM_config.fields['externalMobileRedirect'].remove();
}
},
'close': function() { if (enGMOptChange) { location.reload(); enGMOptChange = false;} },
},
'frame': enGMFrame // Element used for the panel
}
);
// EnstylerJS Config Panel anzeigen
function showEnstylerConfig() {
GM_config.open();
}
//=========== Support functions for actual use =======
// display website in external window
function showUrl(str) {
var myDeco = "innerheight=800,innerwidth=600";
var myName = "enstyler";
// workaround for not working window.focus(): close an existing window first
var myWindowShow = window.open('', myName, "width=100,height=100").close();
myWindowShow = window.open(str, myName, myDeco);
}
// add CSS in to document
function addStyleString(str) {
var node = document.createElement('style');
node.innerHTML = str;
document.body.appendChild(node);
}
// sleep time expects milliseconds, then execute code
// NOTE: code runs in parallel (asnyc)!
// Usage!
// sleepAsync(500).then(() => {
// Do something after the sleep!
// });
function sleepAsync (time) {
return new Promise((resolve) => setTimeout(resolve, time));
}
// ============== START EnstyerJS =============
EnstylerInit();
EnstylerStart();
EnstylerAvatarPopup();
EnstylerDealActions();
// track DOM change Events, debounce: wait 500ms after mutiple events
// then re-apply (somse) changes to dynamic loaded content,
$('.fGrid-last2, .thread-list--type-card').bind("DOMSubtreeModified",$.debounce( 500, function(){
//GM_log('DOMSubtreeModified detected!!!');
EnstylerAvatarPopup();
}));