1/** 2 * Overwrite/bypass <iframe></iframe> height limit imposed by Wordpress 3 * Original idea from bypass-iframe-height-limit plugin by Justin Carboneau 4 * Adapted from original /wp-includes/js/wp-embed.js 5 */ 6(function(window, document) { 7 'use strict'; 8 9 var supportedBrowser = false; 10 11 // Verify if browser is supported 12 if (document.querySelector) { 13 if (window.addEventListener) { 14 supportedBrowser = true; 15 } 16 } 17 18 /** @namespace owihl */ 19 window.owihl = window.owihl || {}; 20 21 if (!!window.owihl.OverwriteIframeHeightLimit) { 22 return; 23 } 24 25 window.owihl.OverwriteIframeHeightLimit = function(e) { 26 var data = e.data; 27 28 // Check if all needed data is provided 29 if (!(data.secret || data.message || data.value)) { 30 return; 31 } 32 33 // Check if data secret is alphanumeric 34 if (/[^a-zA-Z0-9]/.test(data.secret)) { 35 return; 36 } 37 38 // Select all iframes 39 var iframes = document.querySelectorAll('iframe[data-secret="' + data.secret + '"]'), 40 i, source; 41 42 for (i = 0; i < iframes.length; i++) { 43 source = iframes[i]; 44 45 if (e.source !== source.contentWindow) { 46 continue; 47 } 48 49 if ('height' === data.message) { 50 // wp-embed.js clears any added inline styls, that's why we need to create a style element 51 var styleElem = document.getElementById('owihl-style-' + source.getAttribute('data-secret')); 52 var css = 'iframe.wp-embedded-content[data-secret="' + source.getAttribute('data-secret') + 53 '"] { height: ' + parseInt(data.value, 10) + 'px; }'; 54 55 if (styleElem) { 56 styleElem.innerHTML = css; 57 } else { 58 var head = document.head || document.getElementsByTagName('head')[0], 59 style = document.createElement('style'); 60 61 style.type = 'text/css'; 62 style.id = 'owihl-style-' + source.getAttribute('data-secret'); 63 style.appendChild(document.createTextNode(css)); 64 65 head.appendChild(style); 66 } 67 } 68 69 } 70 }; 71 72 if (supportedBrowser) { 73 window.addEventListener('message', window.owihl.OverwriteIframeHeightLimit, false); 74 } else { 75 console.log('Wordpress <iframe> limit is still present because the browser is not supported.'); 76 console.log('For more information : https://medium.com/@wlarch/overwrite-and-bypass-wordpress-iframe-height-dimension-limit-using-javascript-9d5035c89e37'); 77 } 78})(window, document);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.