dcsimg
BOOKMARKLET: Reveal the frameset structure of any webpage - Try it
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Sandip_Chitale
Posted On:   Thursday, January 9, 2003 03:35 PM

// Bookmarklet by Sandip Chitale (sandipchitale@yahoo.com) // Function: Show the frameset based frame structure of any website // Usage:1. Copy these to a file (say - 'c:/bookmarklets') // 2. Visit any website using frames // 3. copy and paste the following line in your address bar starting with the word 'javascript:' // javascript:void((function() {var element=document.createElement('script');element.setAttribute('src','c:/bookmarklets/frametree.js'); document.body.appendChild(element)})()) // 4. Create a bookmark (or also a Links toolbar shortcut in case of IE) for it to acess the functionality with a single click. function tree(){ this.branches = new Array();    More>>
			
// Bookmarklet by Sandip Chitale (sandipchitale@yahoo.com)
// Function: Show the frameset based frame structure of any website
// Usage:1. Copy these to a file (say - 'c:/bookmarklets')
// 2. Visit any website using frames
// 3. copy and paste the following line in your address bar starting with the word 'javascript:'
// javascript:void((function() {var element=document.createElement('script');element.setAttribute('src','c:/bookmarklets/frametree.js'); document.body.appendChild(element)})())
// 4. Create a bookmark (or also a Links toolbar shortcut in case of IE) for it to acess the functionality with a single click.

function tree(){
this.branches = new Array();
this.add = addBranch;
this.write = writeTree;
}

function addBranch(branch){
this.branches[this.branches.length] = branch;
}

function writeTree(output){
var treeString = '';
var numBranches = this.branches.length;
for (var i=0;i < numBranches;i++)
treeString += this.branches[i].write();
output.write(treeString);
}

function branch(text){
this.text = text;
this.write = writeBranch;
this.add = addLeaf;
this.leaves = new Array();
}

function addLeaf(leaf){
this.leaves[this.leaves.length] = leaf;
}

function writeBranch(){
var branchString = '
⋅ ' + this.text + '

';

var numLeaves = this.leaves.length;
for (var j=0;j
branchString += this.leaves[j].write();
branchString += '

';
return branchString;
}

function leaf(text){
this.text = text;
this.write = writeLeaf;
}

function writeLeaf(){
var leafString = '  • ' + this.text + '

';
return leafString;
}

function dumpFrame(frame){
var b = new branch('frame '+frame.name+' ['+(frame.contentWindow? frame.contentWindow.document.title + ' - ' + frame.contentWindow.document.location.pathname : '')+']');
if (frame.contentWindow) {
//dumpProperties(frame.contentWindow, b);
dumpScripts(frame.contentWindow, b);
if (frame.contentWindow.length > 0) {
dumpElements(frame.contentWindow.document.documentElement,b);
}
}
return b;
}

function dumpFrameSet(frameSet){
var b = new branch('frameset ' + ' ' + (frameSet.id ? frameSet.id + ' ' : '') + '(rows= ' + (frameSet.rows ? frameSet.rows : '') + '|' + 'cols= ' + (frameSet.cols ? frameSet.cols : '') +' )');
var children=frameSet.childNodes;
for(var i=0;i
if(children[i].nodeName=='FRAMESET'){
b.add(dumpFrameSet(children[i]));
}
else if(children[i].nodeName=='FRAME') {
b.add(dumpFrame(children[i]));
}
}
return b;
}

function dumpElements(element, b) {
var children=element.childNodes;
for(var i=0;i
if(children[i].nodeName=='FRAMESET'){
b.add(dumpFrameSet(children[i]));
}
else{
dumpElements(children[i]);
}
}
}

function dumpProperties(frame, b){
for (var i in frame) {
if (i == 'domain' || i == 'namespaces' || i == 'innerHTML' || i == 'outerHTML' || i == 'innerText' || i == 'outerText')
{
continue;
}

var propValue = frame[i];
if (propValue == null || propValue == undefined)
{
//b.add(new leaf('undefined ' + i));
} else
{
if (typeof(propValue) == 'object') {
b.add(new branch(typeof(propValue) + ' ' + ' '+ i +' '));
} else if (typeof(propValue) == 'function') {
b.add(new leaf(propValue));
} else if (typeof(propValue) == 'string') {
b.add(new leaf(typeof(propValue) + ' ' + ' '+ i +' ="' + propValue + '"'));
} else
{
b.add(new leaf(typeof(propValue) + ' ' + ' '+ i +' =' + propValue));
}
}
}
}

function dumpScriptProperty(frame, i, b)
{
var propValue = frame[i];
if (propValue == null || propValue == undefined)
{
//b.add(new leaf('undefined ' + i));
} else
{
if (typeof(propValue) == 'object') {
var sb = new branch(typeof(propValue) + ' ' + ' '+ i +' ');
//dumpProperties(propValue, sb);
b.add(sb);
} else if (typeof(propValue) == 'function') {
b.add(new leaf(propValue));
} else if (typeof(propValue) == 'string') {
b.add(new leaf(typeof(propValue) + ' ' + ' '+ i +' ="' + propValue + '"'));
} else
{
b.add(new leaf(typeof(propValue) + ' ' + ' '+ i +' =' + propValue));
}
}
}

function dumpScripts(win, b)
{
var varMatcher = new RegExp("var\s+([a-zA-Z0-9_]+)\s*", "g");
var functionMatcher = new RegExp("function\s+([a-zA-Z0-9_]+)\s*\(", "g");

for (var i = 0; i < win.document.scripts.length; i++) {
if (win.document.scripts[i]) {
var scriptText = win.document.scripts[i].text;
if (scriptText) {
var matched;
while ((matched = varMatcher.exec(scriptText)) != null) {
dumpScriptProperty(win, RegExp.$1, b);
}
while ((matched = functionMatcher.exec(scriptText)) != null) {
dumpScriptProperty(win, RegExp.$1, b);
}
}
}
}
}

function dumpFrameTree(output, win) {
output.body.style.cursor = 'wait';
output.title = 'Working';
output.writeln('
output.writeln('body{');
output.writeln(' font: 8pt Verdana,sans-serif;');
output.writeln(' color: steelblue;');
output.writeln('}');
output.writeln(' ');

var frameTree = new tree();
var b = new branch('window top ['+ win.document.title + ' - ' + win.document.location.pathname + ']');
//dumpProperties(win, b);
dumpScripts(win, b);
dumpElements(win.document.documentElement, b);
frameTree.add(b);
frameTree.write(output);

output.body.style.cursor = 'auto';
output.title = 'Frameset/Frame Structure of ' + win.document.location;
}

function showFrameTree() {
window.open('','frametree','height=600,width=800,scrollbars,resizable').close();
dumpFrameTree(window.open('','frametree','height=600,width=800,scrollbars,resizable').document, window);
}

showFrameTree();
   <<Less
About | Sitemap | Contact