<commit_before>// ==UserScript==
// @name           CSG IFrames
// @namespace      http://jason.karns.name
// @match          https://portal.cardinalsolutions.com/Pages/ViewTimesheets.aspx
// @match          https://empsrv.cardinalsolutions.com/empsrv/Timesheets/*
// @description    Auto-resize IFrames to fit their content
// @author         <NAME>
// @version        1.4
// @date           2012-06-23
// ==/UserScript==

var portal = (document.domain == "portal.cardinalsolutions.com");
document.domain="cardinalsolutions.com";

if(portal){
  (function(iframes) {
    iframes
    .filter(function(iframe){
      return !!iframe;
    })
    .forEach(function(iframe){
      try {
        iframe.addEventListener('load', function(){
          setTimeout(function(){
            var body = (iframe.contentDocument || iframe.contentWindow.document).body;
            //var style = (iframe.style || iframe);
            console.log("H: " + body.scrollHeight + "; W: " + body.scrollWidth);
            iframe.style.height = body.scrollHeight + 30 + "px";
            iframe.style.width = body.scrollWidth + "px";
          }, 3000);
        });
      }
      catch(err) {
        console.error(err);
      }
    });
  })([
    document.getElementById('MSOPageViewerWebPart_WebPartWPQ2')
  ])
}<commit_msg>Include more CSS for robustness<commit_after>// ==UserScript==
// @name           CSG IFrames
// @namespace      http://jason.karns.name
// @match          https://portal.cardinalsolutions.com/Pages/ViewTimesheets.aspx
// @match          https://empsrv.cardinalsolutions.com/empsrv/Timesheets/*
// @description    Auto-resize IFrames to fit their content
// @author         <NAME>
// @version        1.5
// @date           2012-06-23
// ==/UserScript==

var portal = (document.domain == "portal.cardinalsolutions.com");
document.domain="<EMAIL>";

if(portal){
  (function(iframes) {
    iframes
    .filter(function(iframe){
      return !!iframe;
    })
    .forEach(function(iframe){
      try {
        iframe.addEventListener('load', function(){
          setTimeout(function(){
            var body = (iframe.contentDocument || iframe.contentWindow.document).body;
            console.log("H: " + body.scrollHeight + "; W: " + body.scrollWidth);
            iframe.style.height = body.scrollHeight + 30 + 'px';
//            iframe.style.width = body.scrollWidth + 'px';
          }, 3000);
        });
      }
      catch(err) {
        console.error(err);
      }
    });
  })([
    document.querySelector('#MSOPageViewerWebPart_WebPartWPQ2')
  ])

  document.querySelector('#WebPartWPQ2').style['min-height']=document.querySelector('#WebPartWPQ2').style.height;
  document.querySelector('#WebPartWPQ2').style.height='';
  document.querySelectorAll('#MSOZoneCell_WebPartWPQ2 .s4-wpTopTable, #WebPartWPQ2').style.width='100%';
}
{'fraction_non_alphanumeric': 0.15937940761636107, 'fraction_numerical': 0.015162200282087448, 'mean_word_length': 2.524223602484472, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4481002', 'n_tokens_mistral': 905, 'n_tokens_neox': 855, 'n_words': 133}