Skip to content

Instantly share code, notes, and snippets.

View 52cik's full-sized avatar

楼教主 52cik

View GitHub Profile
@52cik
52cik / debug.js
Created April 9, 2016 03:57
监控js错误并上报
// 源: https://sf-static.b0.upaiyun.com/v-5703995e/global/js/debug.js
/*
监控js错误并上报
wtser@sf.gg
*/
window.onerror = function(msg, url, line, col, error) {
if (msg !== "Script error." && !url) {
return true;
}
@52cik
52cik / client.php
Last active April 4, 2016 09:24
php 伪造IP及来源
<?php
$headers = [ // 构造IP
'CLIENT-IP: 8.8.8.8',
'X-FORWARDED-FOR: 8.8.8.8',
];
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://127.0.0.1:8000/server.php');
curl_setopt($ch, CURLOPT_REFERER, 'http://www.baidu.com/'); // 构造来路
@52cik
52cik / events.js
Created March 15, 2016 03:51
jQuery 事件查看
var nodes = document.getElementsByTagName("*");
var events = [];
ev = lookEvents(document);
if (ev) {
events.push({el: document, ev: ev});
}
for (var i=0, l=nodes.length; i<l; i++) {
var ev = lookEvents(nodes[i]);
@52cik
52cik / assert.html
Created March 15, 2016 02:52
js assert 断言函数
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Test Suite</title>
<style>
#results li.pass {color: green;}
#results li.fail {color: red;}
</style>
</head>
@52cik
52cik / visibilitychange.js
Created March 13, 2016 12:32
页面可见性事件 - 标签页被隐藏或显示
(function(document) { // title提示
var titleTime;
var oldTitle = document.title;
var shortcut = document.getElementById('shortcut');
document.addEventListener('visibilitychange', function() {
if (document.hidden) {
document.title = '(●—●)咦,去哪儿啊?';
clearTimeout(titleTime);
shortcut.href = 'images/fail.ico';
@52cik
52cik / hasClass.js
Created March 13, 2016 12:27
hasClass 测试
var some = Array.prototype.some;
function hasClass1(name){
if (!name) {
return false
}
return some.call(this, function(el){
return this.test(el.className)
}, new RegExp('(^|\\s)' + name + '(\\s|$)'));