-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdebug.js
57 lines (50 loc) · 1.46 KB
/
debug.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
/**
* @author Daniel Lochrie
*
* debug.js
* This file determines what ad-network is loaded on the page, and
* calls `lib.js` if DFP is found.
*/
var aps = {};
aps.y = null;
aps.g = null;
/**
* Modify the path to suit your needs.
* GitHib might not be the best place to host this.
*/
aps.scriptPath = 'https://raw.github.com/dlochrie/DFP-Bookmarklets/master/';
console.log('Checking for Ad-Network (Yahoo):');
try {
aps.y = yld_mgr || null;
console.log('Yahoo APT! Found.');
} catch(e) {
console.log('Could not find instance of Yahoo! APT.');
}
console.log('Checking for Ad-Network (Google):');
try {
aps.g = googletag || null;
console.log('Google DFP Found.');
} catch(e) {
console.log('Could not find instance of Google DFP.');
}
aps.loadCommon = function() {
var js = aps.scriptPath + 'lib.js';
var script = document.createElement('script');
script.setAttribute('type', 'text/javascript');
script.setAttribute('src', js);
document.getElementsByTagName('head')[0].appendChild(script);
}
aps.loadStyles = function() {
var css = document.createElement("style");
css.setAttribute("type", "text/css");
css.setAttribute("src", aps.scriptPath + "style.css");
document.getElementsByTagName("head")[0].appendChild(css);
}
if (aps.y) {
alert('This site is using Yahoo! APT. Google DFP was not found.');
} else if(aps.g) {
aps.loadCommon();
//aps.loadStyles();
} else {
alert('No known Ad Network was Found. This site is not using Yahoo APT or DFP Premium.');
}