Last active
February 14, 2023 09:26
-
-
Save sunderls/dfd5293a8b8f24a4ef37189a1d8c1b46 to your computer and use it in GitHub Desktop.
facebook pixel js prettified
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
/*1482118385,,JIT Construction: v2746767,en_US*/ | |
/** | |
* Copyright Facebook Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
try { | |
(function(win, doc, location, history) { | |
'use strict'; | |
var version = "2.5.1"; | |
// var gifPath = 'https://www.facebook.com/tr/'; | |
var gifPath = './'; | |
var fbJsName = '/fbevents.'; | |
var availablePlugins = { | |
IDENTITY: 'plugins.identity.js' // https://connect.facebook.net/en_US/fbevents.plugins.identity.js | |
}; | |
var i = {}; | |
var plugins = []; | |
var scriptTags = null; | |
// https://connect.facebook.net/en_US | |
var fbJsBasePath = null; | |
var regNumber = /^\d+$/; | |
var n = { | |
allowDuplicatePageViews: false | |
}; | |
var Query = function(ua) { | |
var result = { | |
exports: ua | |
}; | |
'use strict'; | |
function Query() { | |
this.list = []; | |
} | |
Query.prototype = { | |
append: function(key, data) { | |
this._append(encodeURIComponent(key), data, 'deep'); | |
}, | |
_append: function(key, data, mode) { | |
// if primitive data | |
if (Object(data) !== data) { | |
this._appendPrimitive(key, data); | |
// if deep copy object | |
} else if (mode === 'deep') { | |
this._appendObject(key, data); | |
} else | |
// shalow copy | |
this._appendPrimitive(key, strintify(data)); | |
}, | |
// for premitive , just use [key, value] | |
_appendPrimitive: function(key, value) { | |
if (value != null) | |
this.list.push([key, value]); | |
}, | |
// for object, flatten them, to `key[name1]`, `key[name2]` | |
_appendObject: function(key, data) { | |
for (var attr in data) | |
if (data.hasOwnProperty(attr)) { | |
var seg = key + '[' + encodeURIComponent(attr) + ']'; | |
this._append(seg, data[attr], 'shallow'); | |
} | |
}, | |
each: function(func) { | |
var data = this.list; | |
for (var i = 0, total = data.length; i < total; i++) | |
func(data[i][0], data[i][1]); | |
}, | |
toQueryString: function () { | |
var result = []; | |
this.each(function(key, value) { | |
result.push(key + '=' + encodeURIComponent(value)); | |
}); | |
return result.join('&'); | |
} | |
}; | |
function strintify(data) { | |
if (typeof JSON === 'undefined' || JSON === null || !JSON.stringify) { | |
return Object.prototype.toString.call(data); | |
} else | |
return JSON.stringify(data); | |
} | |
result.exports = Query; | |
return result.exports; | |
}({}); | |
var util = function(base) { | |
var result = { | |
exports: base | |
}; | |
'use strict'; | |
var key_console = 'console'; | |
var key_error = 'error'; | |
var key_fb_pixel_error = 'Facebook Pixel Error'; | |
var key_fb_pixel_warn = 'Facebook Pixel Warning'; | |
var key_warn = 'warn'; | |
var toString = Object.prototype.toString; | |
var isIE = !('addEventListener' in document); | |
var noop = function lb() {}; | |
var console = win['console'] || {}; | |
var postMessage = win.postMessage || noop; | |
// check isArray | |
function isArray(data) { | |
return Array.isArray ? Array.isArray(data) : toString.call(data) === '[object Array]'; | |
} | |
function logError(msg) { | |
postMessage({ | |
action: 'FB_LOG', | |
logType: key_fb_pixel_error, | |
logMessage: msg | |
}, '*'); | |
if ('error' in console) | |
console['error'](key_fb_pixel_error + ': ' + msg); | |
} | |
function logWarning(msg) { | |
postMessage({ | |
action: 'FB_LOG', | |
logType: key_fb_pixel_warn, | |
logMessage: msg | |
}, '*'); | |
if (key_warn in console) | |
console[key_warn](key_fb_pixel_warn + ': ' + msg); | |
} | |
function listenOnce(target, event, callback) { | |
event = isIE ? 'on' + event : event; | |
var addListenerMethodName = isIE ? 'attachEvent' : 'addEventListener' | |
, removeListenerMethodName = isIE ? 'detachEvent' : 'removeEventListener' | |
, listener = function cb() { | |
target[removeListenerMethodName](event, cb, false); | |
callback(); | |
}; | |
target[addListenerMethod](event, listener, false); | |
} | |
function injectMethod(target, methodName, method) { | |
var originMethod = target[methodName]; | |
target[methodName] = function() { | |
var result = originMethod.apply(this, arguments); | |
method.apply(this, arguments); | |
return result; | |
} | |
; | |
} | |
base.isArray = isArray; | |
base.logError = logError; | |
base.logWarning = logWarning; | |
base.listenOnce = listenOnce; | |
base.injectMethod = injectMethod; | |
return result.exports; | |
}({}); | |
var Validator = function(ua) { | |
var va = { | |
exports: ua | |
}; | |
'use strict'; | |
var wa = /^[+-]?\d+(\.\d+)?$/ | |
, xa = 'number' | |
, ya = 'currency_code' | |
, za = { | |
AED: 1, | |
ARS: 1, | |
AUD: 1, | |
BOB: 1, | |
BRL: 1, | |
CAD: 1, | |
CHF: 1, | |
CLP: 1, | |
CNY: 1, | |
COP: 1, | |
CRC: 1, | |
CZK: 1, | |
DKK: 1, | |
EUR: 1, | |
GBP: 1, | |
GTQ: 1, | |
HKD: 1, | |
HNL: 1, | |
HUF: 1, | |
IDR: 1, | |
ILS: 1, | |
INR: 1, | |
ISK: 1, | |
JPY: 1, | |
KRW: 1, | |
MOP: 1, | |
MXN: 1, | |
MYR: 1, | |
NIO: 1, | |
NOK: 1, | |
NZD: 1, | |
PEN: 1, | |
PHP: 1, | |
PLN: 1, | |
PYG: 1, | |
QAR: 1, | |
RON: 1, | |
RUB: 1, | |
SAR: 1, | |
SEK: 1, | |
SGD: 1, | |
THB: 1, | |
TRY: 1, | |
TWD: 1, | |
USD: 1, | |
UYU: 1, | |
VEF: 1, | |
VND: 1, | |
ZAR: 1 | |
}; | |
var ab = { | |
value: { | |
type: xa, | |
isRequired: true | |
}, | |
currency: { | |
type: ya, | |
isRequired: true | |
} | |
}; | |
var bb = { | |
PageView: {}, | |
ViewContent: {}, | |
Search: {}, | |
AddToCart: {}, | |
AddToWishlist: {}, | |
InitiateCheckout: {}, | |
AddPaymentInfo: {}, | |
Purchase: { | |
validationSchema: ab | |
}, | |
Lead: {}, | |
CompleteRegistration: {}, | |
CustomEvent: { | |
validationSchema: { | |
event: { | |
isRequired: true | |
} | |
} | |
} | |
} | |
var cb = { | |
agent: {} | |
}; | |
var db = Object.prototype.hasOwnProperty; | |
function _Validator(hb, ib, jb) { | |
this.metadata = jb; | |
this.eventName = hb; | |
this.params = ib || {}; | |
this.error = null; | |
this.warnings = []; | |
} | |
_Validator.prototype = { | |
validateMetadata: function() { | |
var ib = this.metadata.toLowerCase() | |
, jb = cb[ib]; | |
if (!jb) | |
return this._error('Unsupported metadata argument: ' + ib); | |
return this; | |
}, | |
validateEvent: function() { | |
var ib = this.eventName | |
, jb = bb[ib]; | |
if (!jb) { | |
this.warnings.push('You are sending a non-standard event \'' + ib + '\'. The ' + 'preferred way to send events is using trackCustom. See ' + 'https://www.facebookmarketingdevelopers.com/pixels/up#sec-custom ' + 'for more information'); | |
return this; | |
} | |
var kb = jb.validationSchema; | |
for (var lb in kb) | |
if (db.call(kb, lb)) { | |
var mb = kb[lb]; | |
if (mb.isRequired === true && !db.call(this.params, lb)) | |
return this._error('Required parameter "' + lb + '" is missing for event "' + ib + '"'); | |
if (mb.type) | |
if (!this._validateParam(lb, mb.type)) | |
return this._error('Parameter "' + lb + '" is invalid for event "' + ib + '"'); | |
} | |
return this; | |
}, | |
_validateParam: function(ib, jb) { | |
var kb = this.params[ib]; | |
switch (jb) { | |
case xa: | |
var lb = wa.test(kb); | |
if (lb && Number(kb) < 0) | |
this.warnings.push('Parameter "' + ib + '" is negative for event "' + this.eventName + '"'); | |
return lb; | |
case ya: | |
return za[kb.toUpperCase()] === 1; | |
} | |
return true; | |
}, | |
_error: function(ib) { | |
this.error = ib; | |
return this; | |
} | |
}; | |
function validateMetadata(meta) { | |
return new _Validator(null,null,meta).validateMetadata(); | |
} | |
function validateEvent(event, data) { | |
return new _Validator(event,data).validateEvent(); | |
} | |
ua.validateMetadata = validateMetadata; | |
ua.validateEvent = validateEvent; | |
return va.exports; | |
}({}); | |
var r = null; | |
// check instal by checking window.fgq which is set by code snippet | |
var fbq = window.fbq; | |
if (!fbq) | |
return util.logError('Pixel code is not installed correctly on this page'); | |
var slice = Array.prototype.slice; | |
var hasOwnProperty = Object.prototype.hasOwnProperty; | |
var currentHref = location.href; | |
var isLegacyInited = false; | |
var isInited = false; | |
var isIframe = win.top !== win; | |
var pixels = []; | |
var initedPixels = {}; | |
var referrer = document.referrer; | |
var ca = {}; | |
var isEmpty = function ua(data) { | |
if (Object.keys) | |
return Object.keys(data).length === 0; | |
for (var wa in data) | |
if (data.hasOwnProperty(wa)) | |
return false; | |
return true; | |
}; | |
// Clone, shallow | |
function Clone(obj) { | |
for (var attr in obj) | |
if (hasOwnProperty.call(obj, attr)) | |
this[atrr] = obj[atrr]; | |
} | |
// run a method call | |
function callMethod(event) { | |
if (!plugins.length) { | |
var args = slice.call(arguments); | |
// fallback for array here? | |
var isArgsInArray = args.length === 1 && util.isArray(args[0]); | |
if (isArgsInArray) | |
args = args[0]; | |
// if method starts with 'report' | |
// do some transformation, seems like legacy code | |
if (event.slice(0, 6) === 'report') { | |
var xa = event.slice(6); | |
if (xa === 'CustomEvent') { | |
xa = (args[1] || {}).event || xa; | |
args = ['trackCustom', xa].concat(args.slice(1)); | |
} else | |
args = ['track', xa].concat(args.slice(1)); | |
} | |
event = args.shift(); | |
switch (event) { | |
// this is legacy | |
case 'addPixelId': | |
w = true; | |
return init.apply(this, args); | |
case 'init': | |
isInited = true; | |
return init.apply(this, args); | |
case 'set': | |
return set.apply(this, args); | |
case 'track': | |
if (regNumber.test(args[0])) | |
return legacyConversionEvent.apply(this, args); | |
if (isArgsInArray) | |
return track.apply(this, args); | |
return ia.apply(this, args); | |
case 'trackCustom': | |
return track.apply(this, args); | |
case 'send': | |
return send.apply(this, args); | |
default: | |
util.logError('Invalid or unknown method name "' + ua + '"'); | |
} | |
} else | |
fbq.queue.push(arguments); | |
} | |
fbq.callMethod = callMethod; | |
// fbq('init'); | |
// related to https://developers.facebook.com/docs/facebook-pixel/pixel-with-ads/conversion-tracking#advanced_match | |
function init(pixelId, va, wa) { | |
if (hasOwnProperty.call(initedPixels, pixelId)) { | |
if (va && isEmpty(initedPixels[pixelId].userData)) { | |
initedPixels[pixelId].userData = va; | |
loadPlugin('IDENTITY'); | |
} else | |
util.logError('Duplicate Pixel ID: ' + pixelId); | |
return; | |
} | |
var xa = { | |
agent: !!wa && wa.agent, | |
id: pixelId, | |
userData: va || {} | |
}; | |
pixels.push(xa); | |
initedPixels[pixelId] = xa; | |
if (va != null) | |
loadPlugin('IDENTITY'); | |
} | |
function set(meta, newMeta, wa) { | |
var xa = Validator.validateMetadata(meta); | |
if (xa.error) | |
util.logError(xa.error); | |
if (xa.warnings) | |
for (var ya = 0; ya < xa.warnings.length; ya++) | |
util.logWarning(xa.warnings[ya]); | |
if (hasOwnProperty.call(aa, wa)) { | |
for (var i = 0, total = pixels.length; i < total; i++) | |
if (pixels[i].id === wa) { | |
pixels[i][meta] = newMeta; | |
break; | |
} | |
} else | |
util.logWarning('Trying to set argument ' + va + ' for uninitialized pixel ID ' + wa); | |
} | |
// ia is legacy ? | |
function ia(event, data) { | |
data = data || {}; | |
var wa = Validator.validateEvent(event, data); | |
if (wa.error) | |
util.logError(wa.error); | |
if (wa.warnings) | |
for (var xa = 0; xa < wa.warnings.length; xa++) | |
util.logWarning(wa.warnings[xa]); | |
if (event === 'CustomEvent') | |
event = data.event; | |
track.call(this, event, data); | |
} | |
// track function | |
function track(event, data) { | |
var wa = this instanceof Clone ? this : n; | |
var isPageview = event === 'PageView'; | |
for (var i = 0, total = pixels.length; i < total; i++) { | |
var methodCall = pixels[i]; | |
if (isPageview && wa.allowDuplicatePageViews === false && ca[methodCall.id] === true) | |
continue; | |
submit(methodCall, event, data); | |
if (isPageview) | |
ca[methodCall.id] = true; | |
} | |
} | |
// send number this is legacy code | |
function legacyConversionEvent(event, data) { | |
submit(null, event, data); | |
} | |
// collect enough data for event | |
function collectData(ua, event, data) { | |
ua = ua || {}; | |
var query = new Query(); | |
query.append('id', ua.id); | |
// 'Pageview', method name ? | |
query.append('ev', event); | |
query.append('dl', currentHref); | |
query.append('rl', referrer); | |
// false | |
query.append('if', isIframe); | |
// timestamp | |
query.append('ts', new Date().valueOf()); | |
query.append('cd', data); | |
query.append('ud', ua.userData); | |
// version | |
query.append('v', version || fbq.version); | |
// | |
query.append('a', ua.agent || fbq.agent); | |
return query; | |
} | |
function send(event, data) { | |
for (var i = 0, total = pixels.length; i < total; i++) | |
submit(pixels[i], event, data); | |
} | |
// send data | |
function submit(ua, event, data) { | |
var xa = collectData(ua, event, data); | |
var ya = xa.toQueryString(); | |
// if length is < 2048, then use get | |
// else use post with a iframe | |
if (2048 > (gifPath + '?' + ya).length) { | |
submitByGet(gifPath, ya); | |
} else | |
submitByPost(gifPath, xa); | |
} | |
// use gif beacon to collect data | |
function submitByGet(path, queryString) { | |
var gif = new Image(); | |
gif.src = path + '?' + queryString; | |
} | |
// create a form & hidden iframe to post | |
function submitByPost(path, query) { | |
var iframeName = 'fb' + Math.random().toString().replace('.', '') | |
, $form = b.createElement('form'); | |
$form.method = 'post'; | |
$form.action = path; | |
$form.target = iframeName; | |
$form.acceptCharset = 'utf-8'; | |
$form.style.display = 'none'; | |
var isIE = !!(a.attachEvent && !a.addEventListener) | |
, tag = isIE ? '<iframe name="' + iframeName + '">' : 'iframe' | |
, $iframe = doc.createElement(tag); | |
$iframe.src = 'javascript:false'; | |
$iframe.id = iframeName; | |
$iframe.name = iframeName; | |
$form.appendChild($iframe); | |
util.listenOnce($iframe, 'load', function() { | |
query.each(function(key, value) { | |
var $input = b.createElement('input'); | |
$input.name = key; | |
$input.value = value; | |
$form.appendChild($input); | |
}); | |
util.listenOnce($iframe, 'load', function() { | |
$form.parentNode.removeChild($form); | |
}); | |
$form.submit(); | |
}); | |
doc.body.appendChild($form); | |
} | |
// flush method call in fbq with order, which are pushed before js is loaded | |
function flushQueue() { | |
while (fbq.queue.length && !plugins.length) { | |
var event = fbq.queue.shift(); | |
callMethod.apply(fbq, event); | |
} | |
} | |
// | |
function updateFbJsBasePath() { | |
scriptTags = doc.getElementsByTagName('script'); | |
for (var i = 0; i < scriptTags.length && !fbJsBasePath; i++) { | |
var segs = scriptTags[i].src.split(fbJsName); | |
if (segs.length > 1) | |
fbJsBasePath = segs[0]; | |
} | |
} | |
// load a plugin by name | |
function loadPlugin(pluginName) { | |
var pluginFileName = availablePlugins[pluginName]; | |
if (pluginFileName) | |
if (i[pluginName]) { | |
i[pluginName]({ | |
pixels: pixels | |
}); | |
} else if (plugins.indexOf(pluginName) === -1) { | |
if (fbJsBasePath == null) | |
updateFbJsBasePath(); | |
plugins.push(pluginName); | |
var $script = doc.createElement('script'); | |
$script.src = fbJsBasePath + fbJsName + pluginFileName; | |
$script.async = true; | |
var firstScriptTag = scriptTags[0]; | |
if (firstScriptTag) | |
firstScriptTag.parentNode.insertBefore($script, firstScriptTag); | |
} | |
} | |
fbq.loadPlugin = loadPlugin; | |
function registerPlugin(ua, va) { | |
if (ua && va) { | |
i[ua] = va; | |
va({ | |
pixels: pixels | |
}); | |
var wa = plugins.indexOf(ua); | |
if (wa > -1) | |
plugins.splice(wa, 1); | |
if (!plugins.length) | |
flushQueue(); | |
} | |
} | |
fbq.registerPlugin = registerPlugin; | |
// legacy | |
if (fbq.pixelId) { | |
isLegacyInited = true; | |
init(s.pixelId); | |
} | |
flushQueue(); | |
// when multiple pixels of different versions are detected. | |
if (isLegacyInited && isInited || win.fbq !== win._fbq) | |
util.logWarning('Multiple pixels with conflicting versions were detected on this page'); | |
if (pixels.length > 1) | |
util.logWarning('Multiple different pixels were detected on this page'); | |
(function() { | |
if (fbq.disablePushState === true) | |
return; | |
// why ? | |
if (!history.pushState || !history.replaceState) | |
return; | |
// seems do something of trakcCustom, pageview? | |
var va = function wa() { | |
oldHref = currentHref; | |
currentHref = location.href; | |
if (currentHref === oldHref) | |
return; | |
var xa = new Clone({ | |
allowDuplicatePageViews: true | |
}); | |
callMethod.call(xa, 'trackCustom', 'PageView'); | |
}; | |
// when pushState | |
util.injectMethod(history, 'pushState', va); | |
// when replaceState | |
util.injectMethod(history, 'replaceState', va); | |
// when popup state | |
win.addEventListener('popstate', va, false); | |
})(); | |
})(window, document, location, history); | |
} catch (e) { | |
// send error back | |
new Image().src = "https:\/\/www.facebook.com\/" + 'common/scribe_endpoint.php?c=jssdk_error&m=' + encodeURIComponent('{"error":"LOAD", "extra": {"name":"' + e.name + '","line":"' + (e.lineNumber || e.line) + '","script":"' + (e.fileName || e.sourceURL || e.script) + '","stack":"' + (e.stackTrace || e.stack) + '","revision":"2746767","namespace":"FB","message":"' + e.message + '"}}'); | |
} |
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
/*1482144920,,JIT Construction: v2746767,en_US*/ | |
/** | |
* Copyright Facebook Inc. | |
* | |
* Licensed under the Apache License, Version 2.0 | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
*/ | |
try { | |
/** | |
* @provides fb.fbevents.plugins.identity | |
* @noframework | |
* @preserve-header | |
* | |
* Copyright (c) 2003, Christoph Bichlmeier | |
* All rights reserved. | |
* | |
* Redistribution and use in source and binary forms, with or without | |
* modification, are permitted provided that the following conditions | |
* are met: | |
* 1. Redistributions of source code must retain the above copyright | |
* notice, this list of conditions and the following disclaimer. | |
* 2. Redistributions in binary form must reproduce the above copyright | |
* notice, this list of conditions and the following disclaimer in the | |
* documentation and/or other materials provided with the distribution. | |
* 3. Neither the name of the copyright holder nor the names of contributors | |
* may be used to endorse or promote products derived from this software | |
* without specific prior written permission. | |
* | |
* THIS SOFTWARE IS PROVIDED BY THE AUTHORS ''AS IS'' AND ANY EXPRESS | |
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | |
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | |
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE | |
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | |
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | |
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR | |
* BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE | |
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, | |
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
* | |
* | |
* str2rstr_utf8 is taken from: | |
* "A JavaScript implementation of the RSA Data Security, Inc. MD5 Message | |
* Digest Algorithm, as defined in RFC 1321." | |
* Version 2.2 Copyright (C) Paul Johnston 1999 - 2009 | |
* Other contributors: Greg Holt, Andrew Kepert, Ydnar, Lostinet | |
* Distributed under the BSD License | |
* | |
*/ | |
(function(a) { | |
var b = function ka(la) { | |
var ma = '', na, oa; | |
for (var pa = 0; pa < la.length; pa++) { | |
na = la.charCodeAt(pa); | |
oa = pa + 1 < la.length ? la.charCodeAt(pa + 1) : 0; | |
if (55296 <= na && na <= 56319 && 56320 <= oa && oa <= 57343) { | |
na = 65536 + ((na & 1023) << 10) + (oa & 1023); | |
pa++; | |
} | |
if (na <= 127) { | |
ma += String.fromCharCode(na); | |
} else if (na <= 2047) { | |
ma += String.fromCharCode(192 | na >>> 6 & 31, 128 | na & 63); | |
} else if (na <= 65535) { | |
ma += String.fromCharCode(224 | na >>> 12 & 15, 128 | na >>> 6 & 63, 128 | na & 63); | |
} else if (na <= 2097151) | |
ma += String.fromCharCode(240 | na >>> 18 & 7, 128 | na >>> 12 & 63, 128 | na >>> 6 & 63, 128 | na & 63); | |
} | |
return ma; | |
}; | |
function c(ka, la) { | |
return la >>> ka | la << 32 - ka; | |
} | |
function d(ka, la, ma) { | |
return ka & la ^ ~ka & ma; | |
} | |
function e(ka, la, ma) { | |
return ka & la ^ ka & ma ^ la & ma; | |
} | |
function f(ka) { | |
return c(2, ka) ^ c(13, ka) ^ c(22, ka); | |
} | |
function g(ka) { | |
return c(6, ka) ^ c(11, ka) ^ c(25, ka); | |
} | |
function h(ka) { | |
return c(7, ka) ^ c(18, ka) ^ ka >>> 3; | |
} | |
function i(ka) { | |
return c(17, ka) ^ c(19, ka) ^ ka >>> 10; | |
} | |
function j(ka, la) { | |
return ka[la & 15] += i(ka[la + 14 & 15]) + ka[la + 9 & 15] + h(ka[la + 1 & 15]); | |
} | |
var k = new Array(1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298) | |
, l = new Array(8) | |
, m = new Array(2) | |
, n = new Array(64) | |
, o = new Array(16) | |
, p = "0123456789abcdef"; | |
function q(ka, la) { | |
var ma = (ka & 65535) + (la & 65535) | |
, na = (ka >> 16) + (la >> 16) + (ma >> 16); | |
return na << 16 | ma & 65535; | |
} | |
function r() { | |
m[0] = m[1] = 0; | |
l[0] = 1779033703; | |
l[1] = 3144134277; | |
l[2] = 1013904242; | |
l[3] = 2773480762; | |
l[4] = 1359893119; | |
l[5] = 2600822924; | |
l[6] = 528734635; | |
l[7] = 1541459225; | |
} | |
function s() { | |
var ka, la, ma, na, oa, pa, qa, ra, sa, ta; | |
ka = l[0]; | |
la = l[1]; | |
ma = l[2]; | |
na = l[3]; | |
oa = l[4]; | |
pa = l[5]; | |
qa = l[6]; | |
ra = l[7]; | |
for (var ua = 0; ua < 16; ua++) | |
o[ua] = n[(ua << 2) + 3] | n[(ua << 2) + 2] << 8 | n[(ua << 2) + 1] << 16 | n[ua << 2] << 24; | |
for (var va = 0; va < 64; va++) { | |
sa = ra + g(oa) + d(oa, pa, qa) + k[va]; | |
if (va < 16) { | |
sa += o[va]; | |
} else | |
sa += j(o, va); | |
ta = f(ka) + e(ka, la, ma); | |
ra = qa; | |
qa = pa; | |
pa = oa; | |
oa = q(na, sa); | |
na = ma; | |
ma = la; | |
la = ka; | |
ka = q(sa, ta); | |
} | |
l[0] += ka; | |
l[1] += la; | |
l[2] += ma; | |
l[3] += na; | |
l[4] += oa; | |
l[5] += pa; | |
l[6] += qa; | |
l[7] += ra; | |
} | |
function t(ka, la) { | |
var ma, na, oa = 0; | |
na = m[0] >> 3 & 63; | |
var pa = la & 63; | |
if ((m[0] += la << 3) < la << 3) | |
m[1]++; | |
m[1] += la >> 29; | |
for (ma = 0; ma + 63 < la; ma += 64) { | |
for (var qa = na; qa < 64; qa++) | |
n[qa] = ka.charCodeAt(oa++); | |
s(); | |
na = 0; | |
} | |
for (var qa = 0; qa < pa; qa++) | |
n[qa] = ka.charCodeAt(oa++); | |
} | |
function u() { | |
var ka = m[0] >> 3 & 63; | |
n[ka++] = 128; | |
if (ka <= 56) { | |
for (var la = ka; la < 56; la++) | |
n[la] = 0; | |
} else { | |
for (var la = ka; la < 64; la++) | |
n[la] = 0; | |
s(); | |
for (var la = 0; la < 56; la++) | |
n[la] = 0; | |
} | |
n[56] = m[1] >>> 24 & 255; | |
n[57] = m[1] >>> 16 & 255; | |
n[58] = m[1] >>> 8 & 255; | |
n[59] = m[1] & 255; | |
n[60] = m[0] >>> 24 & 255; | |
n[61] = m[0] >>> 16 & 255; | |
n[62] = m[0] >>> 8 & 255; | |
n[63] = m[0] & 255; | |
s(); | |
} | |
function v() { | |
var ka = 0 | |
, la = new Array(32); | |
for (var ma = 0; ma < 8; ma++) { | |
la[ka++] = l[ma] >>> 24 & 255; | |
la[ka++] = l[ma] >>> 16 & 255; | |
la[ka++] = l[ma] >>> 8 & 255; | |
la[ka++] = l[ma] & 255; | |
} | |
return la; | |
} | |
function w() { | |
var ka = new String(); | |
for (var la = 0; la < 8; la++) | |
for (var ma = 28; ma >= 0; ma -= 4) | |
ka += p.charAt(l[la] >>> ma & 15); | |
return ka; | |
} | |
function x(ka) { | |
var la = 0; | |
for (var ma = 0; ma < 8; ma++) | |
for (var na = 28; na >= 0; na -= 4) | |
ka[la++] = p.charCodeAt(l[ma] >>> na & 15); | |
} | |
function y(ka, la) { | |
r(); | |
t(ka, ka.length); | |
u(); | |
if (la) { | |
x(la); | |
} else | |
return w(); | |
} | |
function z(ka, la, ma) { | |
if (ka === null || ka === undefined) | |
return null; | |
la = typeof la == 'undefined' ? true : la; | |
if (la) | |
ka = b(ka); | |
return y(ka, ma); | |
} | |
var aa = /^[a-f0-9]{64}$/i | |
, ba = /^[\w!#\$%&'\*\+\/\=\?\^`\{\|\}~\-]+(:?\.[\w!#\$%&'\*\+\/\=\?\^`\{\|\}~\-]+)*@(?:[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9\-]*[a-z0-9])?$/i | |
, ca = /^\s+|\s+$/g | |
, da = Object.prototype.hasOwnProperty; | |
function ea(ka) { | |
return ba.test(ka); | |
} | |
function fa(ka) { | |
if (typeof ka === 'string') | |
return ka.replace(ca, ''); | |
} | |
function ga(ka) { | |
if (typeof ka === 'string') | |
return ka.toLowerCase(); | |
} | |
function ha(ka, la) { | |
var ma = null; | |
switch (ka) { | |
case 'em': | |
case 'email': | |
var na = fa(ga(la)); | |
ma = ea(na) ? na : null; | |
break; | |
default: | |
ma = la; | |
} | |
return ma; | |
} | |
function ia(ka) { | |
var la = ka.pixels || []; | |
for (var ma = 0; ma < la.length; ma++) { | |
var na = la[ma].userData; | |
if (na) { | |
var oa = {}; | |
for (var pa in na) | |
if (da.call(na, pa)) { | |
var qa = na[pa]; | |
if (qa != null && !aa.test(qa)) { | |
qa = ha(pa, qa); | |
if (qa !== null) | |
qa = z(qa); | |
} | |
oa[pa] = qa; | |
} | |
la[ma].userData = oa; | |
} | |
} | |
} | |
var ja = a.fbq; | |
if (!(!ja)) | |
ja.registerPlugin('IDENTITY', ia); | |
})(window); | |
} catch (e) { | |
console.log(e); | |
new Image().src="https:\/\/www.facebook.com\/" + 'common/scribe_endpoint.php?c=jssdk_error&m='+encodeURIComponent('{"error":"LOAD", "extra": {"name":"'+e.name+'","line":"'+(e.lineNumber||e.line)+'","script":"'+(e.fileName||e.sourceURL||e.script)+'","stack":"'+(e.stackTrace||e.stack)+'","revision":"2746767","namespace":"FB","message":"'+e.message+'"}}'); | |
} |
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
!function(f,b,e,v,n,t,s){ | |
if(f.fbq) | |
return; | |
// window.fbq is a function | |
// if fbq has callMethod, it will be run | |
// else push arguments to fbq.queue | |
n=f.fbq=function(){ | |
n.callMethod? n.callMethod.apply(n,arguments):n.queue.push(arguments) | |
}; | |
// _fbq is a flag to determine inited or not | |
if(!f._fbq) f._fbq=n; | |
// fbq.push is itself | |
n.push=n; | |
n.loaded=!0; | |
n.version='2.0'; | |
// fbq.queue | |
n.queue=[]; | |
t=b.createElement(e); | |
t.async=!0; | |
t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, | |
document,'script','https://connect.facebook.net/en_US/fbevents.js'); | |
fbq('init', '1111111111111111', { | |
em: 'someone@example.com' | |
}); | |
fbq('track', 'PageView'); | |
fbq('track', 'Purchase', {currency: 'EUR', value: 15.20}); | |
fbq('trackCustom', 'MyCustomEvent', {custom_param: 'custom_value'}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
最新版貌似已经是navigator的beacon请求了