📄 utilities.js
字号:
result = result.replace(new RegExp("^" + baseURLDomain.escapeForRegExp(), "i"), ""); return result;}function getStyleTextWithShorthands(style){ var cssText = ""; var foundProperties = {}; for (var i = 0; i < style.length; ++i) { var individualProperty = style[i]; var shorthandProperty = style.getPropertyShorthand(individualProperty); var propertyName = (shorthandProperty || individualProperty); if (propertyName in foundProperties) continue; if (shorthandProperty) { var value = getShorthandValue(style, shorthandProperty); var priority = getShorthandPriority(style, shorthandProperty); } else { var value = style.getPropertyValue(individualProperty); var priority = style.getPropertyPriority(individualProperty); } foundProperties[propertyName] = true; cssText += propertyName + ": " + value; if (priority) cssText += " !" + priority; cssText += "; "; } return cssText;}function getShorthandValue(style, shorthandProperty){ var value = style.getPropertyValue(shorthandProperty); if (!value) { // Some shorthands (like border) return a null value, so compute a shorthand value. // FIXME: remove this when http://bugs.webkit.org/show_bug.cgi?id=15823 is fixed. var foundProperties = {}; for (var i = 0; i < style.length; ++i) { var individualProperty = style[i]; if (individualProperty in foundProperties || style.getPropertyShorthand(individualProperty) !== shorthandProperty) continue; var individualValue = style.getPropertyValue(individualProperty); if (style.isPropertyImplicit(individualProperty) || individualValue === "initial") continue; foundProperties[individualProperty] = true; if (!value) value = ""; else if (value.length) value += " "; value += individualValue; } } return value;}function getShorthandPriority(style, shorthandProperty){ var priority = style.getPropertyPriority(shorthandProperty); if (!priority) { for (var i = 0; i < style.length; ++i) { var individualProperty = style[i]; if (style.getPropertyShorthand(individualProperty) !== shorthandProperty) continue; priority = style.getPropertyPriority(individualProperty); break; } } return priority;}function getLonghandProperties(style, shorthandProperty){ var properties = []; var foundProperties = {}; for (var i = 0; i < style.length; ++i) { var individualProperty = style[i]; if (individualProperty in foundProperties || style.getPropertyShorthand(individualProperty) !== shorthandProperty) continue; foundProperties[individualProperty] = true; properties.push(individualProperty); } return properties;}function getUniqueStyleProperties(style){ var properties = []; var foundProperties = {}; for (var i = 0; i < style.length; ++i) { var property = style[i]; if (property in foundProperties) continue; foundProperties[property] = true; properties.push(property); } return properties;}function isNodeWhitespace(){ if (!this || this.nodeType !== Node.TEXT_NODE) return false; if (!this.nodeValue.length) return true; return this.nodeValue.match(/^[\s\xA0]+$/);}function nodeTypeName(){ if (!this) return "(unknown)"; switch (this.nodeType) { case Node.ELEMENT_NODE: return "Element"; case Node.ATTRIBUTE_NODE: return "Attribute"; case Node.TEXT_NODE: return "Text"; case Node.CDATA_SECTION_NODE: return "Character Data"; case Node.ENTITY_REFERENCE_NODE: return "Entity Reference"; case Node.ENTITY_NODE: return "Entity"; case Node.PROCESSING_INSTRUCTION_NODE: return "Processing Instruction"; case Node.COMMENT_NODE: return "Comment"; case Node.DOCUMENT_NODE: return "Document"; case Node.DOCUMENT_TYPE_NODE: return "Document Type"; case Node.DOCUMENT_FRAGMENT_NODE: return "Document Fragment"; case Node.NOTATION_NODE: return "Notation"; } return "(unknown)";}function nodeDisplayName(){ if (!this) return ""; switch (this.nodeType) { case Node.DOCUMENT_NODE: return "Document"; case Node.ELEMENT_NODE: var name = "<" + this.nodeName.toLowerCase(); if (this.hasAttributes()) { var value = this.getAttribute("id"); if (value) name += " id=\"" + value + "\""; value = this.getAttribute("class"); if (value) name += " class=\"" + value + "\""; if (this.nodeName.toLowerCase() === "a") { value = this.getAttribute("name"); if (value) name += " name=\"" + value + "\""; value = this.getAttribute("href"); if (value) name += " href=\"" + value + "\""; } else if (this.nodeName.toLowerCase() === "img") { value = this.getAttribute("src"); if (value) name += " src=\"" + value + "\""; } else if (this.nodeName.toLowerCase() === "iframe") { value = this.getAttribute("src"); if (value) name += " src=\"" + value + "\""; } else if (this.nodeName.toLowerCase() === "input") { value = this.getAttribute("name"); if (value) name += " name=\"" + value + "\""; value = this.getAttribute("type"); if (value) name += " type=\"" + value + "\""; } else if (this.nodeName.toLowerCase() === "form") { value = this.getAttribute("action"); if (value) name += " action=\"" + value + "\""; } } return name + ">"; case Node.TEXT_NODE: if (isNodeWhitespace.call(this)) return "(whitespace)"; return "\"" + this.nodeValue + "\""; case Node.COMMENT_NODE: return "<!--" + this.nodeValue + "-->"; case Node.DOCUMENT_TYPE_NODE: var docType = "<!DOCTYPE " + this.nodeName; if (this.publicId) { docType += " PUBLIC \"" + this.publicId + "\""; if (this.systemId) docType += " \"" + this.systemId + "\""; } else if (this.systemId) docType += " SYSTEM \"" + this.systemId + "\""; if (this.internalSubset) docType += " [" + this.internalSubset + "]"; return docType + ">"; } return this.nodeName.toLowerCase().collapseWhitespace();}function nodeContentPreview(){ if (!this || !this.hasChildNodes || !this.hasChildNodes()) return ""; var limit = 0; var preview = ""; // always skip whitespace here var currentNode = traverseNextNode.call(this, true, this); while (currentNode) { if (currentNode.nodeType === Node.TEXT_NODE) preview += currentNode.nodeValue.escapeHTML(); else preview += nodeDisplayName.call(currentNode).escapeHTML(); currentNode = traverseNextNode.call(currentNode, true, this); if (++limit > 4) { preview += "…"; // ellipsis break; } } return preview.collapseWhitespace();}function objectsAreSame(a, b){ // FIXME: Make this more generic so is works with any wrapped object, not just nodes. // This function is used to compare nodes that might be JSInspectedObjectWrappers, since // JavaScript equality is not true for JSInspectedObjectWrappers of the same node wrapped // with different global ExecStates, we use isSameNode to compare them. if (a === b) return true; if (!a || !b) return false; if (a.isSameNode && b.isSameNode) return a.isSameNode(b); return false;}function isAncestorNode(ancestor){ if (!this || !ancestor) return false; var currentNode = ancestor.parentNode; while (currentNode) { if (objectsAreSame(this, currentNode)) return true; currentNode = currentNode.parentNode; } return false;}function isDescendantNode(descendant){ return isAncestorNode.call(descendant, this);}function firstCommonNodeAncestor(node){ if (!this || !node) return; var node1 = this.parentNode; var node2 = node.parentNode; if ((!node1 || !node2) || !objectsAreSame(node1, node2)) return null; while (node1 && node2) { if (!node1.parentNode || !node2.parentNode) break; if (!objectsAreSame(node1, node2)) break; node1 = node1.parentNode; node2 = node2.parentNode; } return node1;}function nextSiblingSkippingWhitespace(){ if (!this) return; var node = this.nextSibling; while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) node = node.nextSibling; return node;}function previousSiblingSkippingWhitespace(){ if (!this) return; var node = this.previousSibling; while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) node = node.previousSibling; return node;}function firstChildSkippingWhitespace(){ if (!this) return; var node = this.firstChild; while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) node = nextSiblingSkippingWhitespace.call(node); return node;}function lastChildSkippingWhitespace(){ if (!this) return; var node = this.lastChild; while (node && node.nodeType === Node.TEXT_NODE && isNodeWhitespace.call(node)) node = previousSiblingSkippingWhitespace.call(node); return node;}function traverseNextNode(skipWhitespace, stayWithin){ if (!this) return; var node = skipWhitespace ? firstChildSkippingWhitespace.call(this) : this.firstChild; if (node) return node; if (stayWithin && objectsAreSame(this, stayWithin)) return null; node = skipWhitespace ? nextSiblingSkippingWhitespace.call(this) : this.nextSibling; if (node) return node; node = this; while (node && !(skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling) && (!stayWithin || !node.parentNode || !objectsAreSame(node.parentNode, stayWithin))) node = node.parentNode; if (!node) return null; return skipWhitespace ? nextSiblingSkippingWhitespace.call(node) : node.nextSibling;}function traversePreviousNode(skipWhitespace, stayWithin){ if (!this) return; if (stayWithin && objectsAreSame(this, stayWithin)) return null; var node = skipWhitespace ? previousSiblingSkippingWhitespace.call(this) : this.previousSibling; while (node && (skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild) ) node = skipWhitespace ? lastChildSkippingWhitespace.call(node) : node.lastChild; if (node) return node;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -