Last active
April 4, 2017 12:26
-
-
Save cachefiles/c0e9e31fb39cd384829c05f1f24b242d to your computer and use it in GitHub Desktop.
This file contains 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
#!/bin/bash | |
iptables-save -t mangle |grep EBESUCHER|sed "s/-A UNETVPN/-D UNETVPN/g"|xargs -d "\n" -n 1 echo iptables -w -t mangle | bash > /dev/null | |
if ! [ -f /tmp/count.txt ]; then | |
echo -n 0 > /tmp/count.txt; | |
fi; | |
COUNT=$(cat /tmp/count.txt); | |
DATE=$(date "+%D %H:%M:%S") | |
SAVE=$COUNT; | |
if [ $COUNT -eq 8 ]; then | |
NETID=64 | |
COUNT=0 | |
else | |
NETID=$((60+$COUNT)) | |
let COUNT=$(($COUNT+1)) | |
fi; | |
if [ $SAVE -eq 0 ]; then | |
NETID=30 | |
fi; | |
echo -n $COUNT > /tmp/count.txt; | |
echo $DATE: INIT handle request $SAVE 1>&2 | |
RESUME=" UNETVPN -m owner --uid-owner 1003 -m conntrack --ctstate NEW -m comment --comment EBESUCHER -j MARK --set-mark $NETID" | |
iptables -w -t mangle -A $RESUME; | |
RESUME=" UNETVPN -m owner --uid-owner 1003 -m conntrack --ctstate NEW -m comment --comment EBESUCHER -j CONNMARK --set-mark $NETID" | |
iptables -w -t mangle -A $RESUME; | |
MYIP=$(sudo -u ebesucher wget -O - http://members.3322.org/dyndns/getip -o /dev/null) | |
echo $DATE: DONE MYIP is $MYIP SAVE is $SAVE NETID is $NETID time $(date +"%H:%M:%S") 1>&2 | |
CODE=200 | |
if test -z "$MYIP"; then | |
CODE=502; | |
fi; | |
cat << EOF | |
HTTP/1.0 $CODE OK | |
Content-Type: text/plain | |
Content-Length: 5 | |
Access-Control-Allow-Origin: * | |
Cache-Control: max-age=0 | |
Connection: close | |
Hello | |
EOF |
This file contains 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
// ==UserScript== | |
// @name fastswitch | |
// @namespace net.cachefiles.ebesucher | |
// @description auto switch proxy when needed | |
// @include http://www.ebesucher.com/surfbar/pagx.* | |
// @version 1 | |
// @grant none | |
// ==/UserScript== | |
var is_show = 0; | |
function updateInnerHTML(bar, title) { | |
var hrefs = bar.getElementsByTagName("a"); | |
if (hrefs && hrefs.length > 0) { | |
hrefs[0].innerHTML = title; | |
} | |
return; | |
} | |
function getOnHttpReady(e) { | |
var bar = e; | |
function onHttpReady() { | |
if (this.readyState == 4) { | |
if (this.status == 200) { | |
updateInnerHTML(e, "next"); | |
bar.click(); | |
} else { | |
updateInnerHTML(e, "fail"); | |
is_show = 0; | |
} | |
} | |
return; | |
} | |
return onHttpReady; | |
} | |
function requestSwitchProxy(e) { | |
var xhttp = new XMLHttpRequest(); | |
xhttp.onreadystatechange = getOnHttpReady(e); | |
xhttp.open("GET", "http://127.0.0.1:8002/downloads/dolphin/" + new Date().getTime(), true); | |
updateInnerHTML(e, "wait"); | |
xhttp.send(); | |
} | |
function clearDisplay() { | |
var renew_ip = 0; | |
var skipbutton = document.getElementById("skip"); | |
var framesurfs = document.getElementsByTagName("iframe"); | |
if (framesurfs.length >= 1) { | |
for (var i = 0; i < framesurfs.length; i++) { | |
var frame = framesurfs[i]; | |
if (frame.id == "frame0") { | |
if (frame.src != null && | |
frame.src.match(/http:\/\/www\.ebesucher\.com\/surfbaroptimierung.html/) != null) { | |
renew_ip = 1; | |
} | |
break; | |
} | |
} | |
} | |
// <iframe id="frame0" | |
// src="http://www.ebesucher.com/surfbaroptimierung.html | |
if (skipbutton) { | |
if ("inline" != skipbutton.style.display) { | |
updateInnerHTML(skipbutton, ">"); | |
is_show = 0; | |
} else if (is_show < 80 && renew_ip == 1) { | |
if (is_show++ == 1) { | |
requestSwitchProxy(skipbutton); | |
} else if (is_show == 23) { | |
requestSwitchProxy(skipbutton); | |
} else if (is_show == 43) { | |
requestSwitchProxy(skipbutton); | |
} else if (is_show == 63) { | |
requestSwitchProxy(skipbutton); | |
} | |
} | |
} | |
return; | |
} | |
var checkInterval = setInterval(clearDisplay, 3000); | |
function removeJustUnload() { | |
var u = "beforeunload"; | |
var v = unsafeWindow; | |
if (v._eventTypes && v._eventTypes[u]) { | |
var r = v._eventTypes[u]; | |
for (var s = 0; s < r.length; s++) { | |
v.removeEventListener(u, r[s], false); | |
} | |
v._eventTypes[u]= []; | |
} | |
unsafeWindow.showModalDialog = null; | |
unsafeWindow.onbeforeunload = null; | |
unsafeWindow.onunload = null; | |
unsafeWindow.confirm = function() { return false; }; | |
window.showModalDialog = null; | |
window.onbeforeunload = null; | |
window.onunload = null; | |
window.confirm = function() { return false; }; | |
unsafeWindow.popup = null; | |
} | |
removeJustUnload(); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment