This repository has been archived by the owner on Aug 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
49 lines (44 loc) · 1.71 KB
/
content.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
const code = `
<script type="text/javascript">
var adfly_id = 24692891;
var adfly_advert = 'int';
var adfly_protocol = 'http';
var adfly_domain = 'adf.ly';
var exclude_domains = ['example.com'];
var frequency_cap = '5';
var frequency_delay = '5';
var init_delay = '3';
var popunder = true;
</script>
<script src="https://cdn.adf.ly/js/link-converter.js"></script>
<script src="https://cdn.adf.ly/js/entry.js"></script>
`;
const banner = `
<!-- Start of adf.ly banner code -->
<div style="position:relative;width: 728px; height:90px; text-align: center; font-family: verdana; font-size: 10px;">
<div style="position:absolute; top:0; left:0;">
<a href="https://join-adf.ly/24692891">
<img border="0" src="https://cdn.adf.ly/images/banners/adfly.728x90.2.gif" width="728" height="90" title="AdF.ly - shorten links and earn money!" />
</a>
</div>
<div style="height:90px;"></div>
</div>
<!-- End of adf.ly banner code -->
`;
const body = document.body || document.getElementsByTagName("body")[0];
body.insertAdjacentHTML("afterbegin", banner);
console.log("Adf.ly banner inserted into the body element at the top-middle!");
const head = document.head || document.getElementsByTagName("head")[0];
head.insertAdjacentHTML("beforeend", code);
console.log("Adf.ly script inserted into the head element!");
function updateLinks() {
const links = document.getElementsByTagName('a');
for (let i = 0; i < links.length; i++) {
const href = links[i].getAttribute('href');
if (href && !href.startsWith('http://adf.ly/24692891/')) {
links[i].setAttribute('href', `http://adf.ly/24692891/${href}`);
}
}
console.log("Links updated!");
}
updateLinks();