PCYO 评测夜鸥 六度计算世界

少年强 则 中国强

false;

// ==UserScript==
// @name CodeHighLight
// @namespace http://hi.baidu.com/freezesoul
// @include http://hi.baidu.com/freezesoul/blog/item/79ecce112ac7f516b9127bc4.html
// ==/UserScript==

window.setTimeout(function(){
var stylestr = "white-space: pre-wrap;";
stylestr += "white-space: -moz-pre-wrap;";
stylestr += "white-space: -pre-wrap;";
stylestr += "white-space: -o-pre-wrap;";
stylestr += "word-wrap: break-word;";
stylestr += "display: block;";
stylestr += "background-color: #FEF9CB;";
stylestr += "color: #000000;";
stylestr += "font-size: 12px;";
stylestr += "line-height: 15px;";
stylestr += "margin: 10px;";
stylestr += "padding:8px;";
stylestr += "border-left:8px #808080 solid;";
stylestr += "max-height: 600px;";
stylestr += "overflow: auto;";

function CodeHtml() {
var s,r;
if (document.all) {
s = document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.selection.createRange().htmlText;
r = document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.selection.createRange();
r.pasteHTML("<pre style='" + Highlight.outerStyle + "'>" + s + "</pre>");
} else {
s = document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.getSelection();
r = document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.getSelection().getRangeAt(0);
var cs = r.cloneContents();
r.deleteContents();
var newP = document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.createElement("pre");
newP.setAttribute("style", stylestr);
newP.appendChild(cs);
r.insertNode(newP);
}
}
var isCtrl = false;
var fire = function(e) {
e = e || window.event;
if ((e.keyCode || e.which) == 17) isCtrl = true;
if ((e.keyCode || e.which) == 81 && isCtrl == true) {
CodeHtml();
}
}

if (document.addEventListener) {
document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.addEventListener("keydown",fire,false);
}
else if (document.attachEvent) {
document.getElementById("spBlogText___Frame").contentWindow.document.getElementsByTagName("iframe")[0].contentWindow.document.attachEvent("onkeydown",fire);
} }, 1000);

本原创文章未经允许不得转载 | 当前页面:PCYO 评测夜鸥 六度计算世界 » false;

评论