+/**
+ *
+ * could this work by findind all the visible text,
+ * then making them hidden..
+ *
+ * -- make a snapshot of the background..
+ *
+ * -- delete the whole page...
+ * -- show the image as the background.
+ * -- then overlay all the text given their calculated positions..
+ *
+ *
+ *
+ */
-
-function(){
+(function(){
+
+ var camelize = function(a,b){
+ return b.toUpperCase();
+ }
- //var camelize = function(a,b){
- // return b.toUpperCase();
- //}
+
- var fill = function(dom)
+ var fillStyle = function(dom, pstyle)
{
- var style;
- var returns = {};
+ if (!dom || dom.nodeType != 1) {
+ //console.log("SKIP: " + dom.nodeName);
+ return;
+ }
+ //console.log(dom.nodeName);
+
+ var style = window.getComputedStyle(dom, null);
+ if (style.display == 'none' || dom.nodeName == "NOSCRIPT" || dom.nodeName == "SCRIPT" ) {
+ dom.parentElement.removeChild(dom);
+ return;
+ }
+ var cn = [];
+
+ if (dom.childNodes.length > 100) {
+ console.log(dom);
+ throw "too many child nodes?" + dom.childNodes.length ;
+ }
+ for (var i = 0;i < dom.childNodes.length;i++) {
+ cn.push(dom.childNodes[i]);
+ }
+
+ if (cn.length > 100) {
+ console.log(dom);
+ throw "too many child nodes? cn";
+ }
+ for (var i = 0;i < cn.length;i++) {
+
+ //console.log( i + ':'+ cn[i].nodeName);
+ fillStyle(cn[i], style);
+ }
+
+
+ //var pstyle = false;
+ //if (dom.nodeName != 'BODY') {
+ // pstyle = window.getComputedStyle(dom.parentElement, null);
+ //}
+
+ if (dom.nodeName == 'SPAM') {
+ pstyle = false; //?? others??
+ }
+
+ //if (dom.nodeName == 'LI') { throw 'done'; }
+
- style = window.getComputedStyle(dom, null);
for(var i=0;i<style.length;i++){
var prop = style[i];
- //var camel = prop.replace(/\-([a-z])/g, camelize);
+ var camel = prop.replace(/\-([a-z])/g, camelize);
var val = style.getPropertyValue(prop);
//returns[camel] = val;
- dom.style[prop] = val;
+
+ // idea... if the parent has the same style.. then do not apply it to the child?
+ if (pstyle && pstyle[prop] == val) {
+ continue;
+ }
+ //console.log(prop + '=' + val);
+
+ dom.style[camel] = val;
+
+
}
+ var es = dom.getAttribute('style');
+ //console.log(dom.nodeName + '::' + es);
+ dom.setAttribute('style', es);
+
//return returns;
}
- var el = document.querySelector('body');
- fillStyle(el);
- var matches = el.querySelectorAll('*');
- for(var i =0;i < matches.length;i++) {
- fillStyle(matches[i]);
- }
- var matches = document.getElementsByTagName('style');
- for(var i =0;i < matches.length;i++) {
- matches[i].parentElement.removeChild(matches[i]);
- }
-
+ function changeit() {
-
-}
+
+ var el = document.querySelector('body');
+ fillStyle(el), false;
+
+ var matches = document.getElementsByTagName('style');
+ var rm = [];
+ for(var i =0;i < matches.length;i++) {
+ rm.push(matches[i]);
+
+ }
+ var matches = document.getElementsByTagName('link');
+ for(var i =0;i < matches.length;i++) {
+ rm.push(matches[i]);
+ }
+ for(var i =0 ; i < rm.length;i++) {
+ rm[i].parentNode.removeChild(rm[i]);
+ }
+
+
+
+ }
+ changeit();
+ console.log("done");
})();
\ No newline at end of file