This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
atom sync-setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>跳转中...</title> | |
</head> | |
<body> | |
<script> | |
(function(url) { | |
if (/MSIE (\d+\.\d+);/.test(navigator.userAgent)){ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function fireClickEvent(el) { | |
var event; | |
// phantomjs目不支持new Event()的形式:https://github.com/ariya/phantomjs/issues/11289 | |
if (document.createEvent) { | |
event = document.createEvent('MouseEvent'); | |
event.initEvent('click', true, true); | |
el.dispatchEvent(event); | |
} | |
else if (el.fireEvent) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hasAttribute = function(node, attribute) { | |
node = node.getAttributeNode(attribute); | |
return !!(node && node.specified); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 使同域的iframe宽度撑满其所在容器,并且高度自适应其内容 | |
* | |
* @param {Element} iframe . | |
*/ | |
function autoFitIframe(iframe) { | |
var doc = iframe.contentDocument || iframe.contentWindow.document; | |
// 设置iframe宽度 | |
iframe.style.width = '100%'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 执行远程或内敛javascript,支持script中包含document.write | |
* 用于将js广告改为渲染到target, 基于tangram | |
* | |
* executeScript({ | |
* 'target': baidu.g('ad'), | |
* 'url': 'http://ecma.bdimg.com/adtest/0116fb68cf061c3ec55516d4c79946ca.js' | |
* }); | |
* | |
* executeScript({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json/11616993#11616993 | |
var o = {}; | |
o.o = o; | |
var cache = []; | |
JSON.stringify(o, function(key, value) { | |
if (typeof value === 'object' && value !== null) { | |
if (cache.indexOf(value) !== -1) { | |
// Circular reference found, discard key | |
return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(win) { | |
// Do something with the global | |
})(Function('return this')()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*! | |
* jQuery JavaScript Library v2.1.1pre | |
* http://jquery.com/ | |
* | |
* Includes Sizzle.js | |
* http://sizzlejs.com/ | |
* | |
* Copyright 2005, 2014 jQuery Foundation, Inc. and other contributors | |
* Released under the MIT license | |
* http://jquery.org/license |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var inView = function (e) { | |
var clientW = baidu.page.getViewWith(); | |
var clientH = baidu.page.getViewHeight(); | |
var rect = e.getBoundingClientRect(); | |
return (rect.bottom > 0 && rect.top < clientH) | |
&& (rect.right > 0 && rect.left < clientW); | |
}; |