forked from yichahucha/surge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
1,375 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
## Surge | ||
|
||
Remove Weibo ads, promotion and recommend | ||
``` | ||
[Script] | ||
http-response ^https?://m?api\.weibo\.c(n|om)/2/(statuses/(unread|extend|positives/get|(friends|video)(/|_)timeline)|stories/(video_stream|home_list)|(groups|fangle)/timeline|profile/statuses|comments/build_comments|photo/recommend_list|service/picfeed|searchall|cardlist|page|\!/photos/pic_recommend_status) requires-body=1,script-path=https://raw.githubusercontent.com/yichahucha/surge/master/wb_ad.js | ||
http-response ^https?://(sdk|wb)app\.uve\.weibo\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) requires-body=1,script-path=https://raw.githubusercontent.com/yichahucha/surge/master/wb_launch.js | ||
[MITM] | ||
hostname = api.weibo.cn, mapi.weibo.com, *.uve.weibo.com | ||
``` | ||
|
||
Display Netflix TV series and movie's IMDb ratings, Douban ratings, rotten tomato and country/region | ||
``` | ||
[Script] | ||
http-request ^https?://ios\.prod\.ftl\.netflix\.com/iosui/user/.+path=%5B%22videos%22%2C%\d+%22%2C%22summary%22%5D script-path=https://raw.githubusercontent.com/yichahucha/surge/master/netflix_ratings.js | ||
http-response ^https?://ios\.prod\.ftl\.netflix\.com/iosui/user/.+path=%5B%22videos%22%2C%\d+%22%2C%22summary%22%5D requires-body=1,script-path=https://raw.githubusercontent.com/yichahucha/surge/master/nf_rating.js | ||
[MITM] | ||
hostname = ios.prod.ftl.netflix.com | ||
``` | ||
|
||
Display commodity historical price | ||
|
||
JD | ||
``` | ||
[Script] | ||
http-response ^https?://api\.m\.jd\.com/client\.action\?functionId=(wareBusiness|serverConfig) requires-body=1,script-path=https://raw.githubusercontent.com/yichahucha/surge/master/jd_price.js | ||
[MITM] | ||
hostname = api.m.jd.com | ||
``` | ||
|
||
taobao (beta) | ||
``` | ||
[Rule] | ||
# 注意优先级(建议放在第一条) | ||
# 这两条规则可以最大程度缩小匹配的 IP 范围,减少干扰其他应用,不一定适用所有人,可以自己抓包调节 | ||
IP-CIDR, 203.119.144.0/23, REJECT, no-resolve | ||
IP-CIDR, 203.119.175.0/24, REJECT, no-resolve | ||
# 目前这条规则匹配的是部分阿里云 IP 段,其他使用这些阿里云 IP 的应用可能会有问题,谨慎使用 | ||
# IP-CIDR, 203.119.128.0/18, REJECT, no-resolve | ||
[Script] | ||
http-response ^https://trade-acs.m.taobao.com/gw/mtop.taobao.detail.getdetail requires-body=1,script-path=https://raw.githubusercontent.com/yichahucha/surge/master/tb_price.js | ||
[MITM] | ||
hostname = trade-acs.m.taobao.com | ||
``` | ||
|
||
Daily work check-in reminder | ||
``` | ||
[Script] | ||
cron "0 9,18 * * 1-5" script-path=https://raw.githubusercontent.com/yichahucha/surge/master/cron_daily.js | ||
``` | ||
|
||
## Quan-X | ||
|
||
Remove Weibo ads, promotion and recommend | ||
``` | ||
[rewrite_local] | ||
^https?://m?api\.weibo\.c(n|om)/2/(statuses/(unread|extend|positives/get|(friends|video)(/|_)timeline)|stories/(video_stream|home_list)|(groups|fangle)/timeline|profile/statuses|comments/build_comments|photo/recommend_list|service/picfeed|searchall|cardlist|page|\!/photos/pic_recommend_status) url script-response-body wb_ad.js | ||
^https?://(sdk|wb)app\.uve\.weibo\.com(/interface/sdk/sdkad.php|/wbapplua/wbpullad.lua) url script-response-body wb_launch.js | ||
[mitm] | ||
hostname = api.weibo.cn, mapi.weibo.com, *.uve.weibo.com | ||
``` | ||
|
||
Display Netflix TV series and movie's IMDb ratings, Douban ratings, rotten tomato and country/region | ||
``` | ||
[rewrite_local] | ||
^https?://ios\.prod\.ftl\.netflix\.com/iosui/user/.+path=%5B%22videos%22%2C%\d+%22%2C%22summary%22%5D url request-header languages=(.+?)&(.+)&path=%5B%22videos%22%2C%(\d+)%22%2C%22summary%22%5D request-header languages=en-US&$2&path=%5B%22videos%22%2C%$3%22%2C%22summary%22%5D&path=%5B%22videos%22%2C%$3%22%2C%22details%22%5D | ||
^https?://ios\.prod\.ftl\.netflix\.com/iosui/user/.+path=%5B%22videos%22%2C%\d+%22%2C%22summary%22%5D url script-response-body nf_rating.js | ||
[mitm] | ||
hostname = ios.prod.ftl.netflix.com | ||
``` | ||
|
||
Display commodity historical price | ||
|
||
JD | ||
``` | ||
[rewrite_local] | ||
^https?://api\.m\.jd\.com/client\.action\?functionId=(wareBusiness|serverConfig) url script-response-body jd_price.js | ||
[mitm] | ||
hostname = api.m.jd.com | ||
``` | ||
taobao (beta) | ||
``` | ||
[filter_local] | ||
# 注意优先级(建议放在第一条) | ||
# 这两条规则可以最大程度缩小匹配的 IP 范围,减少干扰其他应用,不一定适用所有人,可以自己抓包调节 | ||
ip-cidr, 203.119.144.0/23, reject, no-resolve | ||
ip-cidr, 203.119.175.0/24, reject, no-resolve | ||
# 目前这条规则匹配的是部分阿里云 IP 段,其他使用这些阿里云 IP 的应用可能会有问题,谨慎使用 | ||
# ip-cidr, 203.119.128.0/18, reject, no-resolve | ||
[rewrite_local] | ||
^https://trade-acs.m.taobao.com/gw/mtop.taobao.detail.getdetail url script-response-body tb_price.js | ||
[mitm] | ||
hostname = trade-acs.m.taobao.com | ||
``` |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* | ||
README:https://github.com/yichahucha/surge/tree/master | ||
每日打卡提醒(corn "0 9,18 * * 1-5" 周一到周五,早九晚六)+ 每日壹句(有道词典)+ 跳转钉钉打卡页面(下拉通知点击链接) | ||
*/ | ||
$httpClient.get('https://dict.youdao.com/infoline/style/cardList?mode=publish&client=mobile&style=daily&size=2', function (error, response, data) { | ||
let obj = JSON.parse(data); | ||
let date = new Date(); | ||
let isAM = date.getHours() < 12 ? true : false | ||
let title = 'Clock' + (isAM ? ' in' : ' out') + (isAM ? ' ☀️' : ' 🌙'); | ||
let subtitle = ''; | ||
let content = 'dingtalk://dingtalkclient/page/link?url=https://attend.dingtalk.com/attend/index.html'; | ||
if (!error) { | ||
if (obj && obj.length > 1) { | ||
let yi = obj[1]; | ||
content = yi.title + '\n' + yi.summary + '\n\n' + content; | ||
} | ||
} | ||
$notification.post(title, subtitle, content); | ||
$done(); | ||
}); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,212 @@ | ||
/* | ||
README:https://github.com/yichahucha/surge/tree/master | ||
*/ | ||
|
||
const path1 = "serverConfig"; | ||
const path2 = "wareBusiness"; | ||
const console_log = false; | ||
const url = $request.url; | ||
const body = $response.body; | ||
const isSurge = typeof $httpClient != "undefined" | ||
const isQuanX = typeof $task != "undefined" | ||
|
||
if (url.indexOf(path1) != -1) { | ||
let obj = JSON.parse(body); | ||
delete obj.serverConfig.httpdns; | ||
delete obj.serverConfig.dnsvip; | ||
delete obj.serverConfig.dnsvip_v6; | ||
$done({ body: JSON.stringify(obj) }); | ||
if (console_log) $notify("JD", "", "httpdns closed"); | ||
} | ||
|
||
if (url.indexOf(path2) != -1) { | ||
let obj = JSON.parse(body); | ||
const floors = obj.floors; | ||
const commodity_info = floors[floors.length - 1]; | ||
const shareUrl = commodity_info.data.property.shareUrl; | ||
request_history_price(shareUrl, function (data) { | ||
if (data) { | ||
const lowerword = adword_obj(); | ||
lowerword.data.ad.textColor = "#fe0000"; | ||
let bestIndex = 0; | ||
for (let index = 0; index < floors.length; index++) { | ||
const element = floors[index]; | ||
if (element.mId == lowerword.mId) { | ||
bestIndex = index + 1; | ||
break; | ||
} else { | ||
if (element.sortId > lowerword.sortId) { | ||
bestIndex = index; | ||
break; | ||
} | ||
} | ||
} | ||
if (data.ok == 1 && data.single) { | ||
const price_msgs = history_price_msg(data.single) | ||
const historyword = adword_obj(); | ||
lowerword.data.ad.adword = price_msgs[0]; | ||
historyword.data.ad.adword = price_msgs[1]; | ||
historyword.data.ad.textColor = "#FE9900"; | ||
floors.insert(bestIndex, lowerword); | ||
floors.insert(bestIndex + 1, historyword); | ||
} | ||
if (data.ok == 0 && data.msg.length > 0) { | ||
lowerword.data.ad.adword = "⚠️ " + data.msg; | ||
floors.insert(bestIndex, lowerword); | ||
} | ||
$done({ body: JSON.stringify(obj) }); | ||
} else { | ||
$done({ body }); | ||
} | ||
}) | ||
} | ||
|
||
function history_price_msg(data) { | ||
const rex_match = /\[.*?\]/g; | ||
const rex_exec = /\[(.*),(.*),"(.*)"\]/; | ||
const lower = data.lowerPriceyh; | ||
const lower_date = changeDateFormat(data.lowerDateyh); | ||
const lower_msg = "‼️ 历史最低到手价: ¥" + String(lower) + " " + lower_date | ||
const curret_msg = (data.currentPriceStatus ? " 当前价格" + data.currentPriceStatus : "") + " (仅供参考)"; | ||
const lower_price_msg = lower_msg + curret_msg; | ||
const riqi = "日期: "; | ||
const jiage = "价格: "; | ||
const youhui = "活动: "; | ||
const title_msg = "〽️ 历史价格走势"; | ||
const title_table_msg = riqi + get_blank_space(25 - riqi.length) + jiage + get_blank_space(25 - jiage.length) + youhui; | ||
let history_price_msg = ""; | ||
let start_date = ""; | ||
let end_date = ""; | ||
let date_range_msg = `(最近一年)`; | ||
let list = data.jiagequshiyh.match(rex_match); | ||
list = list.reverse().slice(0, 365); | ||
list.forEach((item, index) => { | ||
if (item.length > 0) { | ||
const result = rex_exec.exec(item); | ||
const dateUTC = new Date(eval(result[1])); | ||
const date = dateUTC.format("yyyy-MM-dd"); | ||
if (index == 0) { | ||
end_date = date; | ||
} | ||
if (index == list.length - 1) { | ||
start_date = date; | ||
} | ||
let price = result[2]; | ||
price = "¥" + String(parseFloat(price)); | ||
if (date == lower_date) { | ||
price += "❗️" | ||
} | ||
const sale = result[3]; | ||
const msg = date + get_blank_space(20 - date.length) + price + get_blank_space(15 - price.length) + sale + "\n"; | ||
history_price_msg += msg; | ||
} | ||
}); | ||
// date_range_msg = `(${start_date} ~ ${end_date})`; | ||
const price_msg = title_msg + " " + date_range_msg + "\n\n" + title_table_msg + "\n" + history_price_msg; | ||
return [lower_price_msg, price_msg]; | ||
} | ||
|
||
function request_history_price(share_url, callback) { | ||
const options = { | ||
url: "https://apapia-history.manmanbuy.com/ChromeWidgetServices/WidgetServices.ashx", | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded;charset=utf-8", | ||
"User-Agent": "Mozilla/5.0 (iPhone; CPU iPhone OS 13_1_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 - mmbWebBrowse - ios" | ||
}, | ||
body: "methodName=getBiJiaInfo_wxsmall&p_url=" + encodeURIComponent(share_url) | ||
} | ||
if (isSurge) { | ||
$httpClient.post(options, function (error, response, data) { | ||
if (!error) { | ||
callback(JSON.parse(data)); | ||
if (console_log) console.log("Data:\n" + data); | ||
} else { | ||
callback(null, null); | ||
if (console_log) console.log("Error:\n" + error); | ||
} | ||
}) | ||
} | ||
if (isQuanX) { | ||
options["method"] = "POST" | ||
$task.fetch(options).then(response => { | ||
callback(JSON.parse(response.body)); | ||
if (console_log) console.log("Data:\n" + response.body); | ||
}, reason => { | ||
callback(null, null); | ||
if (console_log) console.log("Error:\n" + reason.error); | ||
}) | ||
} | ||
} | ||
|
||
function changeDateFormat(cellval) { | ||
const date = new Date(parseInt(cellval.replace("/Date(", "").replace(")/", ""), 10)); | ||
const month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1; | ||
const currentDate = date.getDate() < 10 ? "0" + date.getDate() : date.getDate(); | ||
return date.getFullYear() + "-" + month + "-" + currentDate; | ||
} | ||
|
||
function get_blank_space(length) { | ||
let blank = ""; | ||
for (let index = 0; index < length; index++) { | ||
blank += " "; | ||
} | ||
return blank; | ||
} | ||
|
||
function adword_obj() { | ||
return { | ||
"bId": "eCustom_flo_199", | ||
"cf": { | ||
"bgc": "#ffffff", | ||
"spl": "empty" | ||
}, | ||
"data": { | ||
"ad": { | ||
"adword": "", | ||
"textColor": "#8C8C8C", | ||
"color": "#f23030", | ||
"newALContent": true, | ||
"hasFold": true, | ||
"class": "com.jd.app.server.warecoresoa.domain.AdWordInfo.AdWordInfo", | ||
"adLinkContent": "", | ||
"adLink": "" | ||
} | ||
}, | ||
"mId": "bpAdword", | ||
"refId": "eAdword_0000000028", | ||
"sortId": 13 | ||
} | ||
} | ||
|
||
Array.prototype.insert = function (index, item) { | ||
this.splice(index, 0, item); | ||
}; | ||
|
||
Date.prototype.format = function (fmt) { | ||
var o = { | ||
"y+": this.getFullYear(), | ||
"M+": this.getMonth() + 1, | ||
"d+": this.getDate(), | ||
"h+": this.getHours(), | ||
"m+": this.getMinutes(), | ||
"s+": this.getSeconds(), | ||
"q+": Math.floor((this.getMonth() + 3) / 3), | ||
"S+": this.getMilliseconds() | ||
}; | ||
for (var k in o) { | ||
if (new RegExp("(" + k + ")").test(fmt)) { | ||
if (k == "y+") { | ||
fmt = fmt.replace(RegExp.$1, ("" + o[k]).substr(4 - RegExp.$1.length)); | ||
} | ||
else if (k == "S+") { | ||
var lens = RegExp.$1.length; | ||
lens = lens == 1 ? 3 : lens; | ||
fmt = fmt.replace(RegExp.$1, ("00" + o[k]).substr(("" + o[k]).length - 1, lens)); | ||
} | ||
else { | ||
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length))); | ||
} | ||
} | ||
} | ||
return fmt; | ||
} |
Oops, something went wrong.