Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
lurongkai committed Apr 2, 2013
2 parents 58cba20 + 2ec3d8a commit e16dcf4
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 140 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ http://www.coolshell.cn

#Usage

Unminified Version:
Minified version(obsolated, not recommended):

<script type="text/javascript" src="http://lurongkai.github.com/anti-baidu/js/anti-baidu.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="http://lurongkai.github.com/anti-baidu/js/loader.min.js"></script>

Minified Version:
Specified minified version:

<script type="text/javascript" src="http://lurongkai.github.com/anti-baidu/js/loader.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="http://lurongkai.github.com/anti-baidu/js/anti-baidu-v0.5.min.js"></script>

Single Minified Version(in test, not recommended):
Newest version(recommended):

<script type="text/javascript" src="http://lurongkai.github.com/anti-baidu/js/anti-baidu-v0.5.min.js"></script>

Newest version(in test, not recommended):

<script type="text/javascript" src="http://lurongkai.github.com/anti-baidu/js/anti-baidu-latest.min.js"></script>
<script type="text/javascript" charset="UTF-8" src="http://lurongkai.github.com/anti-baidu/js/anti-baidu-latest.min.js"></script>

#Contributor

Expand Down
128 changes: 64 additions & 64 deletions js/anti-baidu-latest.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
// Author: http://weibo.com/fanweixiao
// Revision: http://weibo.com/lengleng3898
// Version: 0.5

(function(){
"use strict";

var jQuery_cdn = "http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js";
var js_files = "http://lurongkai.github.com/anti-baidu/js/jquery.bpopup-0.8.0.min.js";

var jQueryLoader = function(){
// Only do anything if jQuery isn't defined
if (typeof jQuery === 'undefined') {
var getScript = function(url, successFunction) {
var script = document.createElement('script');
script.src = url;
(function() {
"use strict";

var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
done = true;
// callback function provided as param
successFunction();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};
var js_files = ["http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js", "http://lurongkai.github.com/anti-baidu/js/jquery.bpopup-0.8.0.min.js"];

getScript(jQuery_cdn, function() {
if (typeof jQuery === 'undefined') { // Super failsafe - still somehow failed...
return;
}
});
}
};

var antiBaiduPopup = function($){
$.getScript(js_files[0]);
$(document).ready(function(){
var antiDiv = '<div id="nobaidu_dlg" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-width:450px;min-height:180px;"><img src="http://lurongkai.github.com/anti-baidu/images/nobaidu.jpg" align="left"><p style="margin-left:200px;margin-top: 20px; line-height: 30px;">检测到你还在使用百度这个搜索引擎,<br>作为一个程序员,这是一种自暴自弃!<br><br></p><p align="center" style="margin-top:20px;"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p></div>';
$("body").append(antiDiv);
// Actually, When antiBaidu Popup function be invoked, it is already proved that refer is Baidu.
$('#nobaidu_dlg').bPopup();
});
};

var antiBaiduHandler = function(){
jQueryLoader();
antiBaiduPopup(jQuery);
};

var isReferBaidu = function(){
var url=document.referrer;
if (url && url.search("http://")>-1) {
var refurl = url.match(/:\/\/(.[^/]+)/)[1];
if(refurl.indexOf("baidu.com")>-1){
return true;
}
}
return false;
};

if (isReferBaidu) {
antiBaiduHandler(antiBaiduPopup);
}
})();
var jQueryLoader = function(loadSuccessCallback) {
// Only do anything if jQuery isn't defined
if (typeof jQuery === 'undefined') {
var getScript = function(url, successFunction) {
var script = document.createElement('script');
script.src = url;

var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
done = true;
// callback function provided as param
successFunction(jQuery);
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};

getScript(js_files[0], function() {
if (typeof jQuery === 'undefined') { // Super failsafe - still somehow failed...
return;
}
loadSuccessCallback(jQuery);
});
}
};

var antiBaiduPopup = function($) {
$.getScript(js_files[1]);
$(document).ready(function() {
var antiDiv = '<div id="nobaidu_dlg" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-width:450px;min-height:180px;"><img src="http://lurongkai.github.com/anti-baidu/images/nobaidu.jpg" align="left"><p style="margin-left:200px;margin-top: 20px; line-height: 30px;">检测到你还在使用百度这个搜索引擎,<br>作为一个程序员,这是一种自暴自弃!<br><br></p><p align="center" style="margin-top:20px;"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p></div>';
$("body").append(antiDiv);
// Actually, When antiBaidu Popup function be invoked, it is already proved that refer is Baidu.
$('#nobaidu_dlg').bPopup();
});
};

var antiBaiduHandler = function() {
jQueryLoader(antiBaiduPopup);
};

var isReferBaidu = function() {
var url = document.referrer;
if (url && url.search("http://") > -1) {
var refurl = url.match(/:\/\/(.[^/]+)/)[1];
if (refurl.indexOf("baidu.com") > -1) {
return true;
}
}
return false;
};

if (isReferBaidu) {
antiBaiduHandler();
}
})();
2 changes: 1 addition & 1 deletion js/anti-baidu-latest.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

128 changes: 64 additions & 64 deletions js/anti-baidu-v0.5.js
Original file line number Diff line number Diff line change
@@ -1,69 +1,69 @@
// Author: http://weibo.com/fanweixiao
// Revision: http://weibo.com/lengleng3898
// Version: 0.5

(function(){
"use strict";

var jQuery_cdn = "http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js";
var js_files = "http://lurongkai.github.com/anti-baidu/js/jquery.bpopup-0.8.0.min.js";

var jQueryLoader = function(){
// Only do anything if jQuery isn't defined
if (typeof jQuery === 'undefined') {
var getScript = function(url, successFunction) {
var script = document.createElement('script');
script.src = url;
(function() {
"use strict";

var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
done = true;
// callback function provided as param
successFunction();
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};
var js_files = ["http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js", "http://lurongkai.github.com/anti-baidu/js/jquery.bpopup-0.8.0.min.js"];

getScript(jQuery_cdn, function() {
if (typeof jQuery === 'undefined') { // Super failsafe - still somehow failed...
return;
}
});
}
};

var antiBaiduPopup = function($){
$.getScript(js_files[0]);
$(document).ready(function(){
var antiDiv = '<div id="nobaidu_dlg" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-width:450px;min-height:180px;"><img src="http://lurongkai.github.com/anti-baidu/images/nobaidu.jpg" align="left"><p style="margin-left:200px;margin-top: 20px; line-height: 30px;">检测到你还在使用百度这个搜索引擎,<br>作为一个程序员,这是一种自暴自弃!<br><br></p><p align="center" style="margin-top:20px;"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p></div>';
$("body").append(antiDiv);
// Actually, When antiBaidu Popup function be invoked, it is already proved that refer is Baidu.
$('#nobaidu_dlg').bPopup();
});
};

var antiBaiduHandler = function(){
jQueryLoader();
antiBaiduPopup(jQuery);
};

var isReferBaidu = function(){
var url=document.referrer;
if (url && url.search("http://")>-1) {
var refurl = url.match(/:\/\/(.[^/]+)/)[1];
if(refurl.indexOf("baidu.com")>-1){
return true;
}
}
return false;
};

if (isReferBaidu) {
antiBaiduHandler(antiBaiduPopup);
}
})();
var jQueryLoader = function(loadSuccessCallback) {
// Only do anything if jQuery isn't defined
if (typeof jQuery === 'undefined') {
var getScript = function(url, successFunction) {
var script = document.createElement('script');
script.src = url;

var head = document.getElementsByTagName('head')[0],
done = false;
// Attach handlers for all browsers
script.onload = script.onreadystatechange = function() {
if (!done && (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete')) {
done = true;
// callback function provided as param
successFunction(jQuery);
script.onload = script.onreadystatechange = null;
head.removeChild(script);
}
};
head.appendChild(script);
};

getScript(js_files[0], function() {
if (typeof jQuery === 'undefined') { // Super failsafe - still somehow failed...
return;
}
loadSuccessCallback(jQuery);
});
}
};

var antiBaiduPopup = function($) {
$.getScript(js_files[1]);
$(document).ready(function() {
var antiDiv = '<div id="nobaidu_dlg" style="background-color:#fff; border-radius:15px;color:#000;display:none;padding:20px;min-width:450px;min-height:180px;"><img src="http://lurongkai.github.com/anti-baidu/images/nobaidu.jpg" align="left"><p style="margin-left:200px;margin-top: 20px; line-height: 30px;">检测到你还在使用百度这个搜索引擎,<br>作为一个程序员,这是一种自暴自弃!<br><br></p><p align="center" style="margin-top:20px;"><b><a href="http://coolshell.cn/articles/9308.html">做环保的程序员,从不用百度开始!</a></b></p></div>';
$("body").append(antiDiv);
// Actually, When antiBaidu Popup function be invoked, it is already proved that refer is Baidu.
$('#nobaidu_dlg').bPopup();
});
};

var antiBaiduHandler = function() {
jQueryLoader(antiBaiduPopup);
};

var isReferBaidu = function() {
var url = document.referrer;
if (url && url.search("http://") > -1) {
var refurl = url.match(/:\/\/(.[^/]+)/)[1];
if (refurl.indexOf("baidu.com") > -1) {
return true;
}
}
return false;
};

if (isReferBaidu) {
antiBaiduHandler();
}
})();
2 changes: 1 addition & 1 deletion js/anti-baidu-v0.5.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions test-page.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head>
<title>anti-baidu-test</title>
<script type="text/javascript" src="js/anti-baidu-latest.js" charset="UTF-8"></script>
</head>
<body>
change isReferBaidu before test.
</body>
</html>

0 comments on commit e16dcf4

Please sign in to comment.