テキストブラウザ
URL の上にカーソルを置いて実行するとその内容をエディタ内に表示します。
// -----------------------------------------------------------------------------
// テキストブラウザ
//
// Copyright (c) Kuro. All Rights Reserved.
// www: https://www.haijin-boys.com/
// -----------------------------------------------------------------------------
var indent = "\t";
var sc = new ActiveXObject("ScriptControl");
sc.Language = "VBScript";
sc.AddCode("Function GetTypeName(arg1) : GetTypeName = TypeName(arg1) : End Function");
function getTypeName(arg1) {
return sc.Run("GetTypeName", arg1);
}
var s1 = document.selection.Text;
if (s1 == "") {
var x = document.selection.GetActivePointX(mePosView);
var y = document.selection.GetActivePointY(mePosView);
document.selection.SelectWord();
s1 = document.selection.Text;
document.selection.SetActivePoint(mePosView, x, y);
}
if (s1.substr(0, 7) == "http://" || s1.substr(0, 8) == "https://") {
var o = new ActiveXObject("InternetExplorer.Application");
if (o) {
o.visible = false;
o.navigate(s1);
do {
Sleep(100);
} while(o.Busy);
var s2 = s1 + "\n";
s2 = s2 + o.document.title + "\n";
s2 = s2 + "--------------------------------------------------------------------------------" + "\n";
s2 = s2 + getHtml(o.document.body.childNodes, "");
document.selection.SelectAll();
document.selection.Text = s2;
document.selection.StartOfDocument();
}
}
function getHtml(arg1, arg2) {
var s = "";
for (var i = 0; i < arg1.length; i++) {
var v = arg1[i];
switch (getTypeName(v)) {
case "HTMLBRElement":
s = s + "\n" + arg2;
break;
case "DispHTMLDOMTextNode":
var node;
var prev_node;
node = v.data.replace(/^[ ]+|[ ]+$/g, '');
do {
prev_node = node;
node = node.replace(" ", " ");
} while(node != prev_node);
if (node != "") {
s = s + node;
}
break;
case "HTMLAnchorElement":
s = s + getHtml(v.childNodes, arg2);
s = s + "<\"" + v.href + "\">";
break;
default:
var temp = "";
switch (v.tagName) {
case "P":
case "DIV":
case "TABLE":
case "TR":
case "H1":
case "H2":
case "H3":
case "H4":
case "H5":
case "H6":
case "H7":
case "UL":
case "OL":
case "SELECT":
case "TEXTAREA":
temp = indent;
s = s + "\n" + arg2 + temp;
break;
case "TD":
case "LI":
case "OPTION":
s = s + "\n" + arg2;
break;
default:
break;
}
s = s + getHtml(v.childNodes, arg2 + temp);
if (temp != "") {
s = s + "\n" + arg2;
}
break;
}
}
return s;
}
スポンサーリンク