NOTICE: By continued use of this site you understand and agree to the binding Terms of Service and Privacy Policy.
// ==UserScript== // @name Electrek // @namespace local // @include https://electrek.co/* // @version 1 // @grant none // @license MIT // ==/UserScript== // ads document.body.classList.remove('enable-fallbacks'); if (typeof window.loadAuthorAds == 'function') window.loadAuthorAds = Function.prototype; // fixed top jQuery.fn.scrollToFixed = Function.prototype; window.removeEventListener('scroll', window.onload); window.onload = null; function gmLoadFancybox() { var elt = document.createElement('link'); elt.rel = 'stylesheet'; elt.href = 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.css'; document.body.appendChild(elt); elt = document.createElement('script'); elt.src = 'https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.2.5/jquery.fancybox.min.js'; elt.onload = () => { if (jQuery.fancybox) { jQuery.fancybox.defaults.touch = false; jQuery.fancybox.defaults.idleTime = 0; jQuery.fancybox.defaults.animationDuration = 50; //jQuery.fancybox.defaults.animationEffect = false; jQuery.fancybox.defaults.transitionEffect = false; jQuery.fancybox.defaults.buttons.splice(3, 1); // -share jQuery.fancybox.defaults.onInit = () => { document.body.classList.remove('compensate-for-scrollbar'); }; } }; document.body.appendChild(elt); } jQuery('body').on('post-load', () => { var fancyLoading, elts; // instagram embeds if ((elts = jQuery('.instagram-media:not(.instagram-media-rendered)')).length) { elts.wrap('<div style="position:relative"></div>').before(function() { this.style.maxWidth = ''; return '<a href="' + this.getAttribute('data-instgrm-permalink') + '" data-fancybox="lightbox" data-width style="display:block;position:absolute;top:64px;width:100%;padding-top:100%;outline:0"/>'; }); if (window.instgrm) window.instgrm.Embeds.process(); else { var scr = document.createElement('script'); scr.src = 'https://platform.instagram.com/en_US/embeds.js'; document.body.appendChild(scr); } if (!jQuery.fancybox) fancyLoading = true, gmLoadFancybox(); } // galleries: jetpack carousel -> fancybox if ((elts = jQuery('div.tiled-gallery-item > a:not(data-fancybox)')).length) { elts.each(function() { // arrow notation disables 'this' var v = this.getElementsByTagName('img')[0]; if (v) { this.setAttribute('data-fancybox', 'lightbox'); this.href = v.getAttribute('data-orig-file'); if ((v = v.getAttribute('data-orig-size').split(',')) && v.length == 2) { this.setAttribute('data-width', v[0]); this.setAttribute('data-height', v[1]); } if ((v = this.nextElementSibling) && v.className == 'tiled-gallery-caption') this.setAttribute('data-caption', v.innerHTML); } }); if (!jQuery.fancybox && !fancyLoading) gmLoadFancybox(); } // facebook embeds if (jQuery('fb\\:post:empty').length) { if (window.FB && window.FB.XFBML) window.FB.XFBML.parse(); // see window.facebookEmbed else { var scr = document.createElement('script'); scr.src = 'https://connect.facebook.net/en_US/sdk.js#xfbml=1&version=v2.3'; document.body.appendChild(scr); } } });