Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var hzAdDebug = !1,
- hzVersion = "4.16",
- keywords, adCont, urlPrefix = !hzAdDebug && "https:" == location.protocol ? "https://ssl14.ovh.net/~hoverzoo" : "http://hoverzoom.net",
- validGeoC = ["us"];
- function addAffiliateLinks() {
- try {
- if ("www.youtube.com" == location.host) {
- for (var a = null, c = null, b = document.querySelectorAll("#watch-description-extra-info .metadata-info-title"), d = 0; d < b.length; d++) 0 == b[d].textContent.indexOf("Buy") && (a = b[d].textContent.match(/Buy "(.*)" on/)) && (a = a[1]), -1 < b[d].textContent.indexOf("Artist") && (c = b[d].nextSibling.nextSibling.textContent);
- if (null === a || null === c) return;
- var e = c + " " + a,
- l = document.querySelectorAll('.metadata-info a[href*="itunes"], .metadata-info a[href*="googlemusic"]');
- if (0 == l.length) return;
- var l = l[0],
- g = document.createElement("a");
- g.target = "_blank";
- g.className = "nowrap";
- g.textContent = "Amazon";
- g.title = 'Buy "' + a + '" on Amazon by courtesy of Hover Zoom';
- g.href = "http://www.amazon.com/gp/search?ie=UTF8&camp=1789&creative=9325&index=music&keywords=" + encodeURIComponent(e) + "&linkCode=ur2&tag=hzyt-20";
- l.parentElement.appendChild(g)
- }
- var n = Math.random();
- if ("www.facebook.com" == location.host && (0.7 > n || hzAdDebug))
- if (adCont = document.getElementById("pagelet_ego_pane")) {
- var e = "_default",
- m = localStorage["hzLinkCache " + e];
- m && (m = JSON.parse(m)).expiration > Date.now() ? createAffiliatelinks(m) : (localStorage.removeItem("hzLinkCache " + e), getCountry(function (a) {
- -1 < validGeoC.indexOf(a) && searchItems(e, a, function (a) {
- a = JSON.parse(a);
- keywordsLinks = {
- links: []
- };
- if (a && a.links && 0 < a.links.length)
- for (var b = 0, d = a.links.length; b < d; b++) {
- var c = a.links[b];
- (c.keywords == e || !c.keywords && "_default" == e) && keywordsLinks.links.push(c)
- }
- keywordsLinks.expiration = Date.now() + 6048E5;
- localStorage["hzLinkCache " + e] = JSON.stringify(keywordsLinks);
- createAffiliatelinks(keywordsLinks)
- })
- }))
- }
- } catch (p) {
- if (hzAdDebug) throw p;
- }
- }
- function getCountry(a) {
- var c = document.cookie.match(/hzGeoC=(\w*)/);
- c && 2 == c.length ? a(c[1]) : chrome.runtime.sendMessage({
- action: "ajaxGet",
- url: urlPrefix + "/api/geoc.php"
- }, function (b) {
- b = b.toLowerCase();
- document.cookie = "hzGeoC=" + b + "; expires=" + (new Date(Date.now() + 2592E6)).toUTCString() + "; path=/";
- a && a(b)
- })
- }
- function searchItems(a, c, b) {
- chrome.runtime.sendMessage({
- action: "ajaxGet",
- url: urlPrefix + "/api/amazonlinks/" + c + ".json"
- }, function (a) {
- try {
- a && (a = a.substr(a.indexOf("{")), hzAdDebug && console.log(a), b(a))
- } catch (c) {
- if (hzAdDebug) throw c;
- }
- })
- }
- function createAffiliatelinks(a) {
- try {
- if (a && a.links && a.links.length) {
- for (var c = 0, b = a.links[Math.floor(Math.random() * a.links.length)], d = Date.parse(b.start), e = Date.parse(b.end), l = Date.parse((new Date).toDateString()); !(d <= l && l <= e) && 5 > c++;) b = a.links[Math.floor(Math.random() * a.links.length)], d = Date.parse(b.start), e = Date.parse(b.end);
- var g = b.title || keywords || "",
- n = b.text + "<br>",
- m = b.list_price || b.best_price,
- p = b.img_url,
- k = adCont.querySelector("[data-ad]");
- if (n && b.url) {
- for (; null != k && -1 == k.className.indexOf("ego_unit_container");) k =
- k.parentElement;
- if (null != k) {
- p || (p = chrome.extension.getURL("images/fb-amazon.png"));
- m && (n += "<br><b>" + m + "</b>");
- var f = '<div class="uiSelector inlineBlock emu_x emuEventfad_hide fbEmuLink uiSelectorRight"><div class="wrap"><a id="hzCloseAd" style="visibility: hidden" href="http://hoverzoom.net/aboutads/" target="_blank" title="About this ad"><img src="' + chrome.extension.getURL("images/fb-close.png") + '"></a></div></div>',
- f = f + ('<div class="title" style="color: #3B5998; font-weight: bold; margin-bottom: 4px"><a class="forceLTR" href="' +
- b.url + '" target="_blank">' + g + "</a></div>"),
- f = f + ('<div class="clearfix image_body_block"><a class="emuEvent1 _24x image fbEmuImage _8o _8s lfloat" href="' + b.url + '" target="_blank">'),
- f = f + ('<img src="' + p + '" style="max-width: 100px; max-height: 72px"></a><div>'),
- f = f + ('<div class="_8m"><div class="body"><a class="forceLTR emuEvent1" style="color: #333; text-decoration: none;" href="' + b.url + '" target="_blank">' + n + "</a></div></div>"),
- f = f + "</div>";
- window.removeEventListener("DOMNodeInserted", windowOnDOMNodeInserted);
- var h = document.createElement("div");
- h.id = "hoverZoomAd";
- h.className = "ego_unit";
- h.dataset.keywords = g.replace(/['"]/g, " ");
- h.innerHTML = f;
- k.insertBefore(h, k.children[Math.floor(Math.random() * k.childElementCount)]);
- window.addEventListener("DOMNodeInserted", windowOnDOMNodeInserted);
- var q = document.getElementById("hzCloseAd");
- h.addEventListener("mouseover", function () {
- q.style.visibility = "visible"
- });
- h.addEventListener("mouseout", function () {
- q.style.visibility = "hidden"
- });
- chrome.runtime.sendMessage({
- action: "trackEvent",
- event: {
- category: "Ads",
- action: "FacebookAdDisplayed",
- label: h.dataset.keywords
- }
- });
- h.addEventListener("click", function () {
- chrome.runtime.sendMessage({
- action: "trackEvent",
- event: {
- category: "Ads",
- action: "FacebookAdClicked",
- label: this.dataset.keywords
- }
- })
- })
- }
- }
- }
- } catch (r) {
- if (hzAdDebug) throw r;
- }
- }
- function windowOnDOMNodeInserted(a) {
- a.target && ("ego_column" == a.target.className && a.target.parentElement && "pagelet_ego_pane" == a.target.parentElement.id && !document.getElementById("hoverZoomAd")) && addAffiliateLinks();
- a.target && ("egoRefreshAds" == a.target.id && !document.getElementById("hoverZoomAd")) && addAffiliateLinks()
- }
- chrome.runtime.sendMessage({
- action: "getOptions"
- }, function (a) {
- 2 > a.enableAds && addAffiliateLinks()
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement