// keep_parent_background.js
// RJM Programming
// May, 2017
// As an HTML iframe child and parent defines document.body background, and the child has not defined background, adopt that parent one as the background
//var myStyle = "color: #090";
//document.getElementById("myElement").style.cssText += '; ' + myStyle; // to append
//document.getElementById("myElement").style.cssText = myStyle; // to replace
var kpbadd=false, ifm_data="", ifm_ph="", pdhsone=1, parent_style="";
function nocomment(ins) {
var spareo, outs=ins, cos=["",""];
while (outs.indexOf(String.fromCharCode(10)) != -1) {
outs=outs.replace(String.fromCharCode(10),' ');
}
while (cos.length > 1) {
cos=outs.split('*/');
if (cos.length > 1) {
if (cos[0].indexOf('/*') != -1) {
spareo=cos[0].split('/*');
outs=outs.replace('/*' + spareo[1] + '*/',' ');
} else {
outs=outs.replace('*/',' ');
}
}
}
return filterit(outs);
}
function ifm_check(iois) {
if (iois != null) {
var aconto = (iois.contentWindow || iois.contentDocument);
if (aconto != null) {
if (aconto.document) { aconto = aconto.document; }
if (aconto.body != null) {
//alert(aconto.body.innerHTML);
if (aconto.body.innerHTML.indexOf('
')[0];
ifm_data=aconto.body.innerHTML.replace(prehuh + '>','').replace('
','');
} else {
ifm_data=aconto.body.innerHTML.replace('','').replace('
','');
}
//alert(ifm_data);
var ifm_partsbits = nocomment(ifm_data.replace(/:not \(/g,'~not (').replace(/:NOT \(/g,'~not (').replace(/:Not \(/g,'~not (')).split(':');
css_text_processing(ifm_ph, ifm_partsbits);
}
}
}
}
function css_text_processing(fromarg,betweenstyles) {
var i, j, k, cname='',cvalue=' ', cdname='', oneele=null, oneeleset,cnames;
var thisrule="body", therules=["body"];
for (i=0; i',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else if (therules[j].indexOf('.') != -1) {
if (oneeleset[k].className.toLowerCase() != therules[j].split('.')[1].toLowerCase() || oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else {
if (oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
} else if (fromarg.indexOf("&Style=") != -1) {
oneeleset=document.getElementsByTagName('*');
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else if (therules[j].indexOf('.') != -1) {
if (oneeleset[k].className.toLowerCase() != therules[j].split('.')[1].toLowerCase() || oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else {
if (oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
} else {
oneeleset=parent.document.getElementsByTagName('*');
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else if (therules[j].indexOf('.') != -1) {
if (oneeleset[k].className.toLowerCase() != therules[j].split('.')[1].toLowerCase() || oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else {
if (oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
oneeleset=document.getElementsByTagName('*');
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else if (therules[j].indexOf('.') != -1) {
if (oneeleset[k].className.toLowerCase() != therules[j].split('.')[1].toLowerCase() || oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
} else {
if (oneeleset[k].outerHTML.toLowerCase().replace('>',' ').indexOf('<' + therules[j].toLowerCase() + ' ') == -1) eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
} else if (therules[j].substring(0,1) == '#') { // single ID
oneele=null;
if (fromarg.indexOf("&sTYLE=") != -1) {
oneele=parent.document.getElementById(therules[j].split('#')[1]);
if (oneele) eval("oneele.style." + cdname + "=\"" + cvalue + "\";");
} else if (fromarg.indexOf("&Style=") != -1) {
oneele=document.getElementById(therules[j].split('#')[1]);
if (oneele) eval("oneele.style." + cdname + "=\"" + cvalue + "\";");
} else {
oneele=parent.document.getElementById(therules[j].split('#')[1]);
if (oneele) eval("oneele.style." + cdname + "=\"" + cvalue + "\";");
oneele=document.getElementById(therules[j].split('#')[1]);
if (oneele) eval("oneele.style." + cdname + "=\"" + cvalue + "\";");
}
} else if (therules[j].substring(0,1) == '.') { // single class
oneeleset=[];
if (fromarg.indexOf("&sTYLE=") != -1) {
oneeleset=parent.document.getElementsByTagName('*');
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
} else if (fromarg.indexOf("&Style=") != -1) {
oneeleset=document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
} else {
oneeleset=parent.document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
oneeleset=document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
}
} else { // an element type
oneeleset=[];
if (fromarg.indexOf("&sTYLE=") != -1) {
oneeleset=parent.document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].split('#')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
} else if (fromarg.indexOf("&Style=") != -1) {
oneeleset=document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].split('#')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
} else {
oneeleset=parent.document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].split('#')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
oneeleset=document.getElementsByTagName(therules[j].split('.')[0].split('#')[0].toLowerCase());
for (k=0; k',' ').indexOf('<' + therules[j].split('.')[0].split('#')[0].toLowerCase() + ' ') == 0) {
eval("oneeleset[k].style." + cdname + "=\"" + cvalue + "\";");
}
}
}
}
}
}
}
if (!kpbadd) {
kpbadd=true;
setTimeout(adopt_parent_background_maybe,3000);
setTimeout(forcsscheck,3500);
}
}
function filterit(sb) {
var outsb=sb, sp;
var pbits=sb.split('{');
if (pbits.length > 1) {
outsb=pbits[0].replace(/:/g,'|');
for (var ij=1; ij 1) {
outsb+='}' + sp[1].replace(/:/g,'|');
}
}
} else if (outsb.toLowerCase().replace('https:','').replace('http:','').replace('file:','').indexOf('//') == 0) {
var urls=outsb.split(';');
for (var iurls=0; iurls 0) {
divs[eval(-1 + divs.length)].innerHTML+='';
} else {
document.body.innerHTML+='';
}
}
outsb="";
}
return outsb;
}
function adopt_parent_background_maybe() {
if (parent.document) {
var fromthetop=false;
// Start of more generic ideas regarding passing CSS styling ideas over via ?style=[HTMLstyleString] argument at address bar or at call to external Javascript (ie. this keep_parent_background.js) from parent
var dbs = document.getElementsByTagName('body');
var pdbs = parent.document.getElementsByTagName('body');
var pdhs = parent.document.getElementsByTagName('head');
if (pdhs.length >= pdhsone) {
var passingahih = pdhs[0].innerHTML.split('keep_parent_background.js?');
if (passingahih.length <= 1) {
fromthetop = true;
passingahih = parent.document.URL.split('?');
}
if (passingahih.length > 1) {
var ph = '&' + passingahih[eval(-1 + passingahih.length)].split("'")[0].split('"')[0] + '&';
ifm_ph=ph;
if (ph.toLowerCase().indexOf('&style=') != -1) {
var sbitsare = decodeURIComponent(ph.replace('&STYLE=','&style=').replace('&sTYLE=','&style=').replace('&Style=','&style=').split('&style=')[1].split('&')[0]);
var aname='',avalue='',thenpartsbits;
var partsbits = filterit(sbitsare.replace(/:not \(/g,'~not (').replace(/:NOT \(/g,'~not (').replace(/:Not \(/g,'~not (')).split(':');
if (sbitsare.indexOf('{') != -1) {
css_text_processing(ph,partsbits);
} else if (sbitsare != "") {
for (var iparts=1; iparts')[0].split(' style="');
if (parent_style_bits.length > 1) {
if (parent_style == "") parent_style=(";" + parent_style_bits[1].split('"')[0] + ";").replace(/ ; /g,';').replace(/; /g,';').replace(/ ;/g,';');
if (parent_style.toLowerCase().indexOf(";background") != -1) {
if (dbs[0].outerHTML) {
var self_style_bits=dbs[0].outerHTML.split('>')[0].split(' style="');
if (self_style_bits.length > 1) {
var self_style=(";" + self_style_bits[1].split('"')[0] + ";").replace(/ ; /g,';').replace(/; /g,';').replace(/ ;/g,';');
if (self_style.toLowerCase().indexOf(";background") == -1 || 1 == 1) {
if (parent_style.toLowerCase().indexOf(";background-color:") != -1) {
document.body.style.backgroundColor=parent_style.toLowerCase().split(";background-color:")[1].split(";")[0].trim();
}
}
if (self_style.toLowerCase().indexOf("url(") == -1) {
if (parent_style.toLowerCase().indexOf("url(") != -1) {
var pd=parent.document;
var parifs=pd.getElementsByTagName('iframe');
for (var iparifs=0; iparifs