This repository has been archived by the owner on Apr 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
scan.js
107 lines (99 loc) · 2.62 KB
/
scan.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
chrome.runtime.onMessage.addListener(function (request) {
insertImage(request.href, request.src);
});
Cookies.removeAll = function (attributes) {
Object.keys(Cookies.get()).forEach(function (cookie) {
Cookies.remove(cookie, attributes);
});
};
function isUrl(url) {
return /^http[s]?:\/\/.*/.test(url)
}
function selector(e) {
if (document.body) {
return document.body.querySelector(e);
}
return null;
}
function insertImage(href, src) {
// let newSrc = src.replace(/^http:\/\//i, 'https://');
$(`a[href='${href}']`).prepend(`<img id="theImg" src="${src}" /><br>`);
}
const sites = [
{
"domain": "www.imgbabes.com",
},
{
"domain": "imgdrive.net",
},
{
"domain": "www.iceimg.net",
"redirect": true
},
{
"domain": "i.loli.net",
"direct": true
},
{
"domain": "imgtaxi.com"
},
{
"domain": "imagetwist.com"
}
];
const currentHost = document.location.hostname;
if (_.isUndefined(_.find(sites, ["domain", currentHost]))) {
$("a").each(function () {
let href = this.href;
if (isUrl(href)) {
let linkHost = new URL(href).hostname;
let site = _.find(sites, ["domain", linkHost]);
if (site) {
if (site.direct) {
insertImage(href, href);
} else {
chrome.extension.sendMessage({
type: "newTab",
href: href,
payload: site
});
}
}
}
});
} else {
let src = null;
switch (currentHost) {
case "www.imgbabes.com":
// https://sukebei.nyaa.si/view/2523849
$("input[type='submit']").click();
src = $("#this_image").attr("src");
break;
case "imgtaxi.com":
case "imgwallet.com":
case "imgdrive.net":
// https://sukebei.nyaa.si/view/2523825
$(".iframecti #redirect-wait").hide();
$(".iframecti #redirect-close").show();
let btn = selector("a.overlay_ad_link");
if (btn) {
btn.click();
} else {
src = $(".centred_resized").attr("src");
}
break;
case "imagetwist.com":
try {
closeOverlay();
} catch (e) {
}
src = $(".pic").attr("src");
break;
}
if (src) {
chrome.extension.sendMessage({
type: 'closeTab',
src: src
});
}
}