Skip to content

Instantly share code, notes, and snippets.

@teamtofu teamtofu/aff.js
Created Jul 25, 2019

Embed
What would you like to do?
Affiliate
window["Affiliate"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "../src/Generator.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../node_modules/docile/index.js":
/*!***************************************!*\
!*** ../node_modules/docile/index.js ***!
\***************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("/** @module docile */\r\nmodule.exports = __webpack_require__(/*! ./src/index */ \"../node_modules/docile/src/index.js\");\n\n//# sourceURL=webpack://Affiliate/../node_modules/docile/index.js?");
/***/ }),
/***/ "../node_modules/docile/src/index.js":
/*!*******************************************!*\
!*** ../node_modules/docile/src/index.js ***!
\*******************************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("var domReady = ['loaded', 'interactive', 'complete'].indexOf(document.readyState) >= 0;\r\n\r\nvar attrId = 'data-docile-id';\r\nvar attrStore = 'data-docile-store';\r\n\r\nvar nativeBind = Function.prototype.bind;\r\nvar slice = Array.prototype.slice;\r\n\r\nvar bindTo = function (func, context) {\r\n if (nativeBind && func.bind === nativeBind) {\r\n return nativeBind.apply(func, slice.call(arguments, 1));\r\n }\r\n var args = slice.call(arguments, 2);\r\n return function () {\r\n return func.apply(context, args.concat(slice.call(arguments)));\r\n };\r\n};\r\n\r\nvar error = function () {\r\n if (typeof console === 'object') {\r\n var args = Array.prototype.slice.call(arguments);\r\n var logFunc = Function.prototype.bind.call(console.error, console);\r\n logFunc.apply(console, ['[Docile] '].concat(args));\r\n }\r\n};\r\n\r\nvar createId = function (node) {\r\n var id = node.getAttribute(attrId);\r\n if (!id) {\r\n id = Math.random().toString(36).substr(2);\r\n node.setAttribute(attrId, id);\r\n return id;\r\n }\r\n return id;\r\n};\r\n\r\nvar findNode = function (node) {\r\n if (!domReady) {\r\n error('DOM not loaded. Learn more: https://goo.gl/EsYspK');\r\n return null;\r\n }\r\n if (typeof node === 'object') {\r\n return node;\r\n } else if (typeof node === 'string') {\r\n node = document.getElementById(node);\r\n if (node) return node;\r\n }\r\n error('Unable to resolve node.');\r\n};\r\n\r\nvar findById = function (id) {\r\n return document.querySelector('[' + attrId + '=\"' + id + '\"]');\r\n};\r\n\r\nvar revive = function () {\r\n var data = {store:{},linkStore:{}};\r\n if (!document.head.getAttribute(attrStore)) document.head.setAttribute(attrStore, '{\"store\":{},\"linkStore\":{}}');\r\n try {\r\n data = JSON.parse(document.head.getAttribute(attrStore));\r\n } catch (e) {\r\n error('Data could not be resumed.');\r\n }\r\n return data;\r\n};\r\n\r\nvar persist = function (storeData, linkStoreData) {\r\n try {\r\n document.head.setAttribute(attrStore, JSON.stringify({store: storeData, linkStore: linkStoreData}));\r\n } catch (e) {\r\n error('Data could not be saved.');\r\n }\r\n};\r\n\r\nvar set = function (node, data) {\r\n node = findNode(node);\r\n if (!node) return;\r\n var id = createId(node);\r\n this.store[id] = data;\r\n persist(this.store, this.linkStore);\r\n return this;\r\n};\r\n\r\nvar get = function (node) {\r\n node = findNode(node);\r\n if (!node) return;\r\n var id = createId(node);\r\n return this.store[id];\r\n};\r\n\r\nvar setLink = function (main, alias, node) {\r\n main.linkStore[this.id] = main.linkStore[this.id] || {};\r\n if (typeof alias === 'string') {\r\n node = findNode(node);\r\n if (!node) return;\r\n main.linkStore[this.id][alias] = createId(node);\r\n } else if (typeof alias === 'object') {\r\n for (var i in alias) {\r\n this.set(i, alias[i]);\r\n }\r\n }\r\n persist(main.store, main.linkStore);\r\n return this;\r\n};\r\n\r\nvar getLink = function (main, alias) {\r\n main.linkStore[this.id] = main.linkStore[this.id] || {};\r\n if (alias) {\r\n if (typeof alias !== 'string') return error('Link name must be a string.');\r\n return findById(main.linkStore[this.id][alias]);\r\n } else {\r\n var links = {};\r\n for (var i in main.linkStore[this.id]) {\r\n links[i] = findById(main.linkStore[this.id][i]);\r\n }\r\n return links;\r\n }\r\n};\r\n\r\nvar getLinkData = function (main, alias) {\r\n if (alias) {\r\n return main.get(this.get(alias));\r\n } else {\r\n var listLinks = this.get();\r\n for (var i in listLinks) {\r\n listLinks[i] = main.get(listLinks[i]);\r\n }\r\n return listLinks;\r\n }\r\n};\r\n\r\nvar link = function (node) {\r\n node = findNode(node);\r\n if (!node) return;\r\n var id = createId(node);\r\n var DocileLink = new Object();\r\n DocileLink.id = id;\r\n DocileLink.set = bindTo(setLink, DocileLink, this);\r\n DocileLink.get = bindTo(getLink, DocileLink, this);\r\n DocileLink.getData = bindTo(getLinkData, DocileLink, this);\r\n return DocileLink;\r\n};\r\n\r\n/**\r\n * Stores data about DOM nodes.\r\n * @property {function} set - Set data\r\n * @property {function} get - Get data\r\n * @property {function} link - Links nodes\r\n */\r\nvar Docile = new Object();\r\n/**\r\n * @param {(string|Object)} node - The DOM node or node id\r\n */\r\nDocile.get = bindTo(get, Docile);\r\n/**\r\n * @param {(string|Object)} node - The DOM node or node id\r\n * @param {*} data - The data to be stored\r\n */\r\nDocile.set = bindTo(set, Docile);\r\n/**\r\n * @param {(string|Object)} node - The DOM node for accessing a link\r\n */\r\nDocile.link = bindTo(link, Docile);\r\n\r\nvar initialData = revive();\r\nDocile.store = initialData.store || {};\r\nDocile.linkStore = initialData.linkStore || {};\r\n\r\nwindow.addEventListener('DOMContentLoaded', function () {\r\n domReady = true;\r\n});\r\n\r\nmodule.exports = Docile;\n\n//# sourceURL=webpack://Affiliate/../node_modules/docile/src/index.js?");
/***/ }),
/***/ "../node_modules/querystringify/index.js":
/*!***********************************************!*\
!*** ../node_modules/querystringify/index.js ***!
\***********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\nvar has = Object.prototype.hasOwnProperty\n , undef;\n\n/**\n * Decode a URI encoded string.\n *\n * @param {String} input The URI encoded string.\n * @returns {String|Null} The decoded string.\n * @api private\n */\nfunction decode(input) {\n try {\n return decodeURIComponent(input.replace(/\\+/g, ' '));\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Attempts to encode a given input.\n *\n * @param {String} input The string that needs to be encoded.\n * @returns {String|Null} The encoded string.\n * @api private\n */\nfunction encode(input) {\n try {\n return encodeURIComponent(input);\n } catch (e) {\n return null;\n }\n}\n\n/**\n * Simple query string parser.\n *\n * @param {String} query The query string that needs to be parsed.\n * @returns {Object}\n * @api public\n */\nfunction querystring(query) {\n var parser = /([^=?&]+)=?([^&]*)/g\n , result = {}\n , part;\n\n while (part = parser.exec(query)) {\n var key = decode(part[1])\n , value = decode(part[2]);\n\n //\n // Prevent overriding of existing properties. This ensures that build-in\n // methods like `toString` or __proto__ are not overriden by malicious\n // querystrings.\n //\n // In the case if failed decoding, we want to omit the key/value pairs\n // from the result.\n //\n if (key === null || value === null || key in result) continue;\n result[key] = value;\n }\n\n return result;\n}\n\n/**\n * Transform a query string to an object.\n *\n * @param {Object} obj Object that should be transformed.\n * @param {String} prefix Optional prefix.\n * @returns {String}\n * @api public\n */\nfunction querystringify(obj, prefix) {\n prefix = prefix || '';\n\n var pairs = []\n , value\n , key;\n\n //\n // Optionally prefix with a '?' if needed\n //\n if ('string' !== typeof prefix) prefix = '?';\n\n for (key in obj) {\n if (has.call(obj, key)) {\n value = obj[key];\n\n //\n // Edge cases where we actually want to encode the value to an empty\n // string instead of the stringified value.\n //\n if (!value && (value === null || value === undef || isNaN(value))) {\n value = '';\n }\n\n key = encodeURIComponent(key);\n value = encodeURIComponent(value);\n\n //\n // If we failed to encode the strings, we should bail out as we don't\n // want to add invalid strings to the query.\n //\n if (key === null || value === null) continue;\n pairs.push(key +'='+ value);\n }\n }\n\n return pairs.length ? prefix + pairs.join('&') : '';\n}\n\n//\n// Expose the module.\n//\nexports.stringify = querystringify;\nexports.parse = querystring;\n\n\n//# sourceURL=webpack://Affiliate/../node_modules/querystringify/index.js?");
/***/ }),
/***/ "../node_modules/requires-port/index.js":
/*!**********************************************!*\
!*** ../node_modules/requires-port/index.js ***!
\**********************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("\n\n/**\n * Check if we're required to add a port number.\n *\n * @see https://url.spec.whatwg.org/#default-port\n * @param {Number|String} port Port number we need to check\n * @param {String} protocol Protocol we need to check against.\n * @returns {Boolean} Is it a default port for the given protocol\n * @api private\n */\nmodule.exports = function required(port, protocol) {\n protocol = protocol.split(':')[0];\n port = +port;\n\n if (!port) return false;\n\n switch (protocol) {\n case 'http':\n case 'ws':\n return port !== 80;\n\n case 'https':\n case 'wss':\n return port !== 443;\n\n case 'ftp':\n return port !== 21;\n\n case 'gopher':\n return port !== 70;\n\n case 'file':\n return false;\n }\n\n return port !== 0;\n};\n\n\n//# sourceURL=webpack://Affiliate/../node_modules/requires-port/index.js?");
/***/ }),
/***/ "../node_modules/url-parse/index.js":
/*!******************************************!*\
!*** ../node_modules/url-parse/index.js ***!
\******************************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
"use strict";
eval("/* WEBPACK VAR INJECTION */(function(global) {\n\nvar required = __webpack_require__(/*! requires-port */ \"../node_modules/requires-port/index.js\")\n , qs = __webpack_require__(/*! querystringify */ \"../node_modules/querystringify/index.js\")\n , slashes = /^[A-Za-z][A-Za-z0-9+-.]*:\\/\\//\n , protocolre = /^([a-z][a-z0-9.+-]*:)?(\\/\\/)?([\\S\\s]*)/i\n , whitespace = '[\\\\x09\\\\x0A\\\\x0B\\\\x0C\\\\x0D\\\\x20\\\\xA0\\\\u1680\\\\u180E\\\\u2000\\\\u2001\\\\u2002\\\\u2003\\\\u2004\\\\u2005\\\\u2006\\\\u2007\\\\u2008\\\\u2009\\\\u200A\\\\u202F\\\\u205F\\\\u3000\\\\u2028\\\\u2029\\\\uFEFF]'\n , left = new RegExp('^'+ whitespace +'+');\n\n/**\n * Trim a given string.\n *\n * @param {String} str String to trim.\n * @public\n */\nfunction trimLeft(str) {\n return (str ? str : '').toString().replace(left, '');\n}\n\n/**\n * These are the parse rules for the URL parser, it informs the parser\n * about:\n *\n * 0. The char it Needs to parse, if it's a string it should be done using\n * indexOf, RegExp using exec and NaN means set as current value.\n * 1. The property we should set when parsing this value.\n * 2. Indication if it's backwards or forward parsing, when set as number it's\n * the value of extra chars that should be split off.\n * 3. Inherit from location if non existing in the parser.\n * 4. `toLowerCase` the resulting value.\n */\nvar rules = [\n ['#', 'hash'], // Extract from the back.\n ['?', 'query'], // Extract from the back.\n function sanitize(address) { // Sanitize what is left of the address\n return address.replace('\\\\', '/');\n },\n ['/', 'pathname'], // Extract from the back.\n ['@', 'auth', 1], // Extract from the front.\n [NaN, 'host', undefined, 1, 1], // Set left over value.\n [/:(\\d+)$/, 'port', undefined, 1], // RegExp the back.\n [NaN, 'hostname', undefined, 1, 1] // Set left over.\n];\n\n/**\n * These properties should not be copied or inherited from. This is only needed\n * for all non blob URL's as a blob URL does not include a hash, only the\n * origin.\n *\n * @type {Object}\n * @private\n */\nvar ignore = { hash: 1, query: 1 };\n\n/**\n * The location object differs when your code is loaded through a normal page,\n * Worker or through a worker using a blob. And with the blobble begins the\n * trouble as the location object will contain the URL of the blob, not the\n * location of the page where our code is loaded in. The actual origin is\n * encoded in the `pathname` so we can thankfully generate a good \"default\"\n * location from it so we can generate proper relative URL's again.\n *\n * @param {Object|String} loc Optional default location object.\n * @returns {Object} lolcation object.\n * @public\n */\nfunction lolcation(loc) {\n var globalVar;\n\n if (typeof window !== 'undefined') globalVar = window;\n else if (typeof global !== 'undefined') globalVar = global;\n else if (typeof self !== 'undefined') globalVar = self;\n else globalVar = {};\n\n var location = globalVar.location || {};\n loc = loc || location;\n\n var finaldestination = {}\n , type = typeof loc\n , key;\n\n if ('blob:' === loc.protocol) {\n finaldestination = new Url(unescape(loc.pathname), {});\n } else if ('string' === type) {\n finaldestination = new Url(loc, {});\n for (key in ignore) delete finaldestination[key];\n } else if ('object' === type) {\n for (key in loc) {\n if (key in ignore) continue;\n finaldestination[key] = loc[key];\n }\n\n if (finaldestination.slashes === undefined) {\n finaldestination.slashes = slashes.test(loc.href);\n }\n }\n\n return finaldestination;\n}\n\n/**\n * @typedef ProtocolExtract\n * @type Object\n * @property {String} protocol Protocol matched in the URL, in lowercase.\n * @property {Boolean} slashes `true` if protocol is followed by \"//\", else `false`.\n * @property {String} rest Rest of the URL that is not part of the protocol.\n */\n\n/**\n * Extract protocol information from a URL with/without double slash (\"//\").\n *\n * @param {String} address URL we want to extract from.\n * @return {ProtocolExtract} Extracted information.\n * @private\n */\nfunction extractProtocol(address) {\n address = trimLeft(address);\n var match = protocolre.exec(address);\n\n return {\n protocol: match[1] ? match[1].toLowerCase() : '',\n slashes: !!match[2],\n rest: match[3]\n };\n}\n\n/**\n * Resolve a relative URL pathname against a base URL pathname.\n *\n * @param {String} relative Pathname of the relative URL.\n * @param {String} base Pathname of the base URL.\n * @return {String} Resolved pathname.\n * @private\n */\nfunction resolve(relative, base) {\n if (relative === '') return base;\n\n var path = (base || '/').split('/').slice(0, -1).concat(relative.split('/'))\n , i = path.length\n , last = path[i - 1]\n , unshift = false\n , up = 0;\n\n while (i--) {\n if (path[i] === '.') {\n path.splice(i, 1);\n } else if (path[i] === '..') {\n path.splice(i, 1);\n up++;\n } else if (up) {\n if (i === 0) unshift = true;\n path.splice(i, 1);\n up--;\n }\n }\n\n if (unshift) path.unshift('');\n if (last === '.' || last === '..') path.push('');\n\n return path.join('/');\n}\n\n/**\n * The actual URL instance. Instead of returning an object we've opted-in to\n * create an actual constructor as it's much more memory efficient and\n * faster and it pleases my OCD.\n *\n * It is worth noting that we should not use `URL` as class name to prevent\n * clashes with the global URL instance that got introduced in browsers.\n *\n * @constructor\n * @param {String} address URL we want to parse.\n * @param {Object|String} [location] Location defaults for relative paths.\n * @param {Boolean|Function} [parser] Parser for the query string.\n * @private\n */\nfunction Url(address, location, parser) {\n address = trimLeft(address);\n\n if (!(this instanceof Url)) {\n return new Url(address, location, parser);\n }\n\n var relative, extracted, parse, instruction, index, key\n , instructions = rules.slice()\n , type = typeof location\n , url = this\n , i = 0;\n\n //\n // The following if statements allows this module two have compatibility with\n // 2 different API:\n //\n // 1. Node.js's `url.parse` api which accepts a URL, boolean as arguments\n // where the boolean indicates that the query string should also be parsed.\n //\n // 2. The `URL` interface of the browser which accepts a URL, object as\n // arguments. The supplied object will be used as default values / fall-back\n // for relative paths.\n //\n if ('object' !== type && 'string' !== type) {\n parser = location;\n location = null;\n }\n\n if (parser && 'function' !== typeof parser) parser = qs.parse;\n\n location = lolcation(location);\n\n //\n // Extract protocol information before running the instructions.\n //\n extracted = extractProtocol(address || '');\n relative = !extracted.protocol && !extracted.slashes;\n url.slashes = extracted.slashes || relative && location.slashes;\n url.protocol = extracted.protocol || location.protocol || '';\n address = extracted.rest;\n\n //\n // When the authority component is absent the URL starts with a path\n // component.\n //\n if (!extracted.slashes) instructions[3] = [/(.*)/, 'pathname'];\n\n for (; i < instructions.length; i++) {\n instruction = instructions[i];\n\n if (typeof instruction === 'function') {\n address = instruction(address);\n continue;\n }\n\n parse = instruction[0];\n key = instruction[1];\n\n if (parse !== parse) {\n url[key] = address;\n } else if ('string' === typeof parse) {\n if (~(index = address.indexOf(parse))) {\n if ('number' === typeof instruction[2]) {\n url[key] = address.slice(0, index);\n address = address.slice(index + instruction[2]);\n } else {\n url[key] = address.slice(index);\n address = address.slice(0, index);\n }\n }\n } else if ((index = parse.exec(address))) {\n url[key] = index[1];\n address = address.slice(0, index.index);\n }\n\n url[key] = url[key] || (\n relative && instruction[3] ? location[key] || '' : ''\n );\n\n //\n // Hostname, host and protocol should be lowercased so they can be used to\n // create a proper `origin`.\n //\n if (instruction[4]) url[key] = url[key].toLowerCase();\n }\n\n //\n // Also parse the supplied query string in to an object. If we're supplied\n // with a custom parser as function use that instead of the default build-in\n // parser.\n //\n if (parser) url.query = parser(url.query);\n\n //\n // If the URL is relative, resolve the pathname against the base URL.\n //\n if (\n relative\n && location.slashes\n && url.pathname.charAt(0) !== '/'\n && (url.pathname !== '' || location.pathname !== '')\n ) {\n url.pathname = resolve(url.pathname, location.pathname);\n }\n\n //\n // We should not add port numbers if they are already the default port number\n // for a given protocol. As the host also contains the port number we're going\n // override it with the hostname which contains no port number.\n //\n if (!required(url.port, url.protocol)) {\n url.host = url.hostname;\n url.port = '';\n }\n\n //\n // Parse down the `auth` for the username and password.\n //\n url.username = url.password = '';\n if (url.auth) {\n instruction = url.auth.split(':');\n url.username = instruction[0] || '';\n url.password = instruction[1] || '';\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n //\n // The href is just the compiled result.\n //\n url.href = url.toString();\n}\n\n/**\n * This is convenience method for changing properties in the URL instance to\n * insure that they all propagate correctly.\n *\n * @param {String} part Property we need to adjust.\n * @param {Mixed} value The newly assigned value.\n * @param {Boolean|Function} fn When setting the query, it will be the function\n * used to parse the query.\n * When setting the protocol, double slash will be\n * removed from the final url if it is true.\n * @returns {URL} URL instance for chaining.\n * @public\n */\nfunction set(part, value, fn) {\n var url = this;\n\n switch (part) {\n case 'query':\n if ('string' === typeof value && value.length) {\n value = (fn || qs.parse)(value);\n }\n\n url[part] = value;\n break;\n\n case 'port':\n url[part] = value;\n\n if (!required(value, url.protocol)) {\n url.host = url.hostname;\n url[part] = '';\n } else if (value) {\n url.host = url.hostname +':'+ value;\n }\n\n break;\n\n case 'hostname':\n url[part] = value;\n\n if (url.port) value += ':'+ url.port;\n url.host = value;\n break;\n\n case 'host':\n url[part] = value;\n\n if (/:\\d+$/.test(value)) {\n value = value.split(':');\n url.port = value.pop();\n url.hostname = value.join(':');\n } else {\n url.hostname = value;\n url.port = '';\n }\n\n break;\n\n case 'protocol':\n url.protocol = value.toLowerCase();\n url.slashes = !fn;\n break;\n\n case 'pathname':\n case 'hash':\n if (value) {\n var char = part === 'pathname' ? '/' : '#';\n url[part] = value.charAt(0) !== char ? char + value : value;\n } else {\n url[part] = value;\n }\n break;\n\n default:\n url[part] = value;\n }\n\n for (var i = 0; i < rules.length; i++) {\n var ins = rules[i];\n\n if (ins[4]) url[ins[1]] = url[ins[1]].toLowerCase();\n }\n\n url.origin = url.protocol && url.host && url.protocol !== 'file:'\n ? url.protocol +'//'+ url.host\n : 'null';\n\n url.href = url.toString();\n\n return url;\n}\n\n/**\n * Transform the properties back in to a valid and full URL string.\n *\n * @param {Function} stringify Optional query stringify function.\n * @returns {String} Compiled version of the URL.\n * @public\n */\nfunction toString(stringify) {\n if (!stringify || 'function' !== typeof stringify) stringify = qs.stringify;\n\n var query\n , url = this\n , protocol = url.protocol;\n\n if (protocol && protocol.charAt(protocol.length - 1) !== ':') protocol += ':';\n\n var result = protocol + (url.slashes ? '//' : '');\n\n if (url.username) {\n result += url.username;\n if (url.password) result += ':'+ url.password;\n result += '@';\n }\n\n result += url.host + url.pathname;\n\n query = 'object' === typeof url.query ? stringify(url.query) : url.query;\n if (query) result += '?' !== query.charAt(0) ? '?'+ query : query;\n\n if (url.hash) result += url.hash;\n\n return result;\n}\n\nUrl.prototype = { set: set, toString: toString };\n\n//\n// Expose the URL parser and some additional properties that might be useful for\n// others or testing.\n//\nUrl.extractProtocol = extractProtocol;\nUrl.location = lolcation;\nUrl.trimLeft = trimLeft;\nUrl.qs = qs;\n\nmodule.exports = Url;\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"../node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack://Affiliate/../node_modules/url-parse/index.js?");
/***/ }),
/***/ "../node_modules/webpack/buildin/global.js":
/*!*************************************************!*\
!*** ../node_modules/webpack/buildin/global.js ***!
\*************************************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n\n\n//# sourceURL=webpack://Affiliate/../node_modules/webpack/buildin/global.js?");
/***/ }),
/***/ "../src/Affiliate.js":
/*!***************************!*\
!*** ../src/Affiliate.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classPrivateFieldSet(receiver, privateMap, value) { var descriptor = privateMap.get(receiver); if (!descriptor) { throw new TypeError(\"attempted to set private field on non-instance\"); } if (descriptor.set) { descriptor.set.call(receiver, value); } else { if (!descriptor.writable) { throw new TypeError(\"attempted to set read only private field\"); } descriptor.value = value; } return value; }\n\nfunction _classPrivateFieldGet(receiver, privateMap) { var descriptor = privateMap.get(receiver); if (!descriptor) { throw new TypeError(\"attempted to get private field on non-instance\"); } if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\n// url-parse parses and modifies urls\nvar parseURL = __webpack_require__(/*! url-parse */ \"../node_modules/url-parse/index.js\"); // docile stores data relative to DOM elements\n\n\nvar Docile = __webpack_require__(/*! docile */ \"../node_modules/docile/index.js\"); // log safely implements console.log for older browsers\n\n\nvar Log = __webpack_require__(/*! ./Log */ \"../src/Log.js\"); // Check for MutationObserver\n\n\nvar canObserve = !(typeof window.MutationObserver === 'undefined');\n/**\r\n * @class Manages stateful affiliation\r\n */\n\nvar Affiliate =\n/*#__PURE__*/\nfunction () {\n function Affiliate(config) {\n var _this = this;\n\n _classCallCheck(this, Affiliate);\n\n _state.set(this, {\n writable: true,\n value: {\n attached: false,\n config: {},\n hosts: []\n }\n });\n\n _observer.set(this, {\n writable: true,\n value: null\n });\n\n _modifyURL.set(this, {\n writable: true,\n value: function value(url, node, tag) {\n // Check if URL is already modified\n var linkData = Docile.get(node) || {};\n if (linkData.is && linkData.is === url.href) return; // Preserve the original URL\n\n var originalURL = url.href;\n\n _this.log(false, 'Discovered URL: ' + url.href); // Change query variables\n\n\n url.set('query', _objectSpread({}, url.query, {}, tag.query)); // Run the modification function\n\n if (typeof tag.modify === 'function') {\n try {\n var returnedURL = tag.modify(url);\n url = parseURL(returnedURL.href || returnedURL, true);\n } catch (e) {\n Log(true, e);\n }\n } // Replace certain parts of the url\n\n\n url = url.href;\n\n for (var i in tag.replace) {\n url = url.replace(tag.replace[i].from, tag.replace[i].to);\n } // Update the href tag and save the url to the DOM node\n\n\n node.setAttribute('href', url);\n Docile.set(node, {\n was: originalURL,\n is: url\n });\n }\n });\n\n _defineProperty(this, \"attach\", function () {\n // Cannot attach twice\n if (_classPrivateFieldGet(_this, _state).attached) return; // Get readyState, or the loading state of the DOM\n\n var _document = document,\n readyState = _document.readyState;\n\n if (readyState === 'complete' || readyState === 'interactive' || readyState === 'loaded') {\n // Set attached to true\n _classPrivateFieldGet(_this, _state).attached = true; // Run through the entire body tag\n\n _this.traverse();\n } else {\n // Wait until the DOM loads\n return window.addEventListener('DOMContentLoaded', _this.attach);\n }\n\n if (canObserve) {\n // Attach the observer\n _classPrivateFieldGet(_this, _observer).observe(document.body, {\n childList: true,\n subtree: true,\n attributes: true,\n characterData: true,\n attributeFilter: ['href']\n });\n } else {\n _this.log(false, 'Browser does not support MutationObserver.');\n }\n });\n\n _defineProperty(this, \"detach\", function () {\n if (!canObserve) return;\n _classPrivateFieldGet(_this, _state).attached = false;\n\n _classPrivateFieldGet(_this, _observer).disconnect();\n\n _this.log(false, 'Observer disconnected.');\n });\n\n // Extend the configuration\n config = _objectSpread({\n tags: []\n }, config);\n\n for (var i in config.tags) {\n // Convert a single host to an array\n if (typeof config.tags[i].hosts === 'string') config.tags[i].hosts = [config.tags[i].hosts]; // Extend proper tag configuration\n\n config.tags[i] = _objectSpread({\n hosts: [],\n query: {},\n replace: []\n }, config.tags[i]); // Append hosts to full list\n\n _classPrivateFieldGet(this, _state).hosts = _classPrivateFieldGet(this, _state).hosts.concat(config.tags[i].hosts);\n } // Set logging function\n\n\n this.log = config.log ? Log : function () {};\n this.log(false, 'New Instance', config); // Check is MutationObserver is supported\n\n if (canObserve) {\n // Initialize MutationObserver\n _classPrivateFieldSet(this, _observer, new window.MutationObserver(function (mutations) {\n // This function is called for every DOM mutation\n // Has a mutation been logged\n var emitted = false;\n\n for (var _i in mutations) {\n // If the attributes of the link have been modified\n if (mutations[_i].type === 'attributes') {\n // Skip links without an href\n if (mutations[_i].attributeName !== 'href') continue;\n\n var href = mutations[_i].target.getAttribute('href');\n\n var linkData = Docile.get(mutations[_i].target) || {}; // Skip links without a modified href\n\n if (linkData.is && linkData.is === href) continue;\n } // Only calls on first mutation\n\n\n if (!emitted) {\n _this.log(false, 'DOM Mutation');\n\n emitted = true;\n } // Scan the node and subnodes if there are any\n\n\n _this.traverse(mutations[_i].target);\n }\n }));\n } // Set internal state\n\n\n _classPrivateFieldGet(this, _state).config = config;\n }\n /**\r\n * Manual function to search the DOM for unaffiliated links\r\n * \r\n * @function\r\n * @param {object=} nodeSet The node to traverse for links (default: document.body)\r\n */\n\n\n _createClass(Affiliate, [{\n key: \"traverse\",\n value: function traverse(nodeSet) {\n // Default to searching everything\n if (!nodeSet) nodeSet = document.body;\n this.log(false, 'Traversing DOM...'); // Reduce link collection to array\n\n var collection = nodeSet.getElementsByTagName('a');\n var nodes = [];\n\n for (var i in collection) {\n if (Object.hasOwnProperty.call(collection, i)) nodes[i] = collection[i];\n } // If the nodeSet is a single link, turn to array\n\n\n if (nodeSet.nodeName.toLowerCase() === 'a') nodes = [nodeSet]; // Go through each link\n\n for (var o in nodes) {\n // Check if it is actually linking\n if (!nodes[o] || !nodes[o].getAttribute('href')) continue; // Parse the URL via url-parse\n\n var url = parseURL(nodes[o].getAttribute('href') || '', true); // Only modify hosts provided.\n\n if (_classPrivateFieldGet(this, _state).hosts.indexOf(url.host) === -1) continue;\n\n for (var _i2 in _classPrivateFieldGet(this, _state).config.tags) {\n if (_classPrivateFieldGet(this, _state).config.tags[_i2].hosts.indexOf(url.host) !== -1) {\n _classPrivateFieldGet(this, _modifyURL).call(this, url, nodes[o], _classPrivateFieldGet(this, _state).config.tags[_i2]);\n }\n }\n }\n }\n /**\r\n * Modify the URL of a matching link while preserving the original link state\r\n * \r\n * @private\r\n * @function\r\n * @param {string} url Original url string\r\n * @param {object} node Anchor link node\r\n * @param {object} tag Matching configuration tag\r\n */\n\n }]);\n\n return Affiliate;\n}();\n\nvar _state = new WeakMap();\n\nvar _observer = new WeakMap();\n\nvar _modifyURL = new WeakMap();\n\nmodule.exports = Affiliate;\n\n//# sourceURL=webpack://Affiliate/../src/Affiliate.js?");
/***/ }),
/***/ "../src/AutoConfig.js":
/*!****************************!*\
!*** ../src/AutoConfig.js ***!
\****************************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/* Utility function for parsing data-aff syntax */\nvar BRK = function BRK(data, delimiter) {\n if (_typeof(data) === 'object') {\n for (var i in data) {\n data[i] = BRK(data[i], delimiter);\n }\n } else if (typeof data === 'string') {\n data = data.split(delimiter);\n\n for (var o in data) {\n data[o] = data[o].trim();\n }\n }\n\n return data;\n};\n/* Setup automatic configuration */\n\n\nvar AutoConfig = function AutoConfig() {\n var scriptNode = document.getElementById('aff-js');\n\n if (_typeof(scriptNode) === 'object' && scriptNode !== null) {\n var nodeData = scriptNode.getAttribute('data-aff');\n\n if (typeof nodeData === 'string') {\n var parsedData = BRK(BRK(BRK(BRK(nodeData, '!'), ':'), ','), '=');\n var tags = [];\n\n for (var i in parsedData) {\n var tag = {\n hosts: [],\n query: {}\n };\n\n for (var o in parsedData[i][0]) {\n tag.hosts.push(parsedData[i][0][o][0]);\n }\n\n for (var u in parsedData[i][1]) {\n tag.query[parsedData[i][1][u][0]] = parsedData[i][1][u][1];\n }\n\n tags.push(tag);\n }\n\n return {\n tags: tags\n };\n }\n }\n};\n\nmodule.exports = AutoConfig;\n\n//# sourceURL=webpack://Affiliate/../src/AutoConfig.js?");
/***/ }),
/***/ "../src/Generator.js":
/*!***************************!*\
!*** ../src/Generator.js ***!
\***************************/
/*! no static exports found */
/***/ (function(module, exports, __webpack_require__) {
eval("function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classPrivateFieldGet(receiver, privateMap) { var descriptor = privateMap.get(receiver); if (!descriptor) { throw new TypeError(\"attempted to get private field on non-instance\"); } if (descriptor.get) { return descriptor.get.call(receiver); } return descriptor.value; }\n\n// Docile stores data relative to DOM elements\nvar Docile = __webpack_require__(/*! docile */ \"../node_modules/docile/index.js\"); // AutoConfig stores data relative to DOM elements\n\n\nvar AutoConfig = __webpack_require__(/*! ./AutoConfig */ \"../src/AutoConfig.js\"); // Affiliate is the main class for affiliate instances\n\n\nvar Affiliate = __webpack_require__(/*! ./Affiliate */ \"../src/Affiliate.js\"); // Log safely implements console.log for older browsers\n\n\nvar Log = __webpack_require__(/*! ./Log */ \"../src/Log.js\");\n/**\r\n * @class Set up the global Affiliate export\r\n */\n\n\nvar Generator =\n/*#__PURE__*/\nfunction () {\n function Generator() {\n var _this = this;\n\n _classCallCheck(this, Generator);\n\n _state.set(this, {\n writable: true,\n value: {\n instances: [],\n auto: null\n }\n });\n\n _defineProperty(this, \"create\", function (config) {\n var Instance = new Affiliate(config);\n\n _classPrivateFieldGet(_this, _state).instances.push(Instance);\n\n return Instance;\n });\n\n _defineProperty(this, \"detachAll\", function () {\n for (var i in _classPrivateFieldGet(_this, _state).instances) {\n _classPrivateFieldGet(_this, _state).instances[i].detach();\n }\n });\n\n _defineProperty(this, \"revert\", function () {\n _this.detachAll();\n\n var nodes = [].slice.call(document.body.getElementsByTagName('a'));\n\n for (var i in nodes) {\n var linkData = Docile.get(nodes[i]);\n\n if (linkData && linkData.was) {\n nodes[i].setAttribute('href', linkData.was);\n Docile.set(nodes[i], {});\n }\n }\n });\n\n try {\n var config = AutoConfig();\n\n if (_typeof(config) === 'object') {\n var auto = this.create(config);\n Log(false, auto);\n _classPrivateFieldGet(this, _state).auto = auto;\n auto.attach();\n }\n } catch (e) {\n Log(true, e);\n }\n }\n /**\r\n * Create a new Affiliate instance\r\n * \r\n * @function\r\n * @param {object} config Configuration options for Affiliate\r\n * @returns {object} Affiliate instance\r\n */\n\n\n _createClass(Generator, [{\n key: \"instances\",\n\n /**\r\n * Expose the instance list\r\n * \r\n * @type {Array.<object>}\r\n */\n get: function get() {\n return [].concat(_classPrivateFieldGet(this, _state).instances);\n }\n /**\r\n * Detach automatic link traversal\r\n * \r\n * @function\r\n */\n\n }]);\n\n return Generator;\n}();\n\nvar _state = new WeakMap();\n\nmodule.exports = new Generator();\n\n//# sourceURL=webpack://Affiliate/../src/Generator.js?");
/***/ }),
/***/ "../src/Log.js":
/*!*********************!*\
!*** ../src/Log.js ***!
\*********************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("function _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/**\r\n * log handles formatting and doesn't throw errors is console is undefined\r\n * \r\n * @module affiliate/src/Log\r\n */\nmodule.exports = function (isError) {\n if ((typeof console === \"undefined\" ? \"undefined\" : _typeof(console)) === 'object') {\n var args = Array.prototype.slice.call(arguments, 1);\n var logFunc = isError ? console.error : console.log;\n logFunc = Function.prototype.bind.call(logFunc, console);\n logFunc.apply(console, ['[Affiliate] '].concat(args));\n }\n};\n\n//# sourceURL=webpack://Affiliate/../src/Log.js?");
/***/ })
/******/ });
window["AffiliatePluginAmazon"] =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId]) {
/******/ return installedModules[moduleId].exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ i: moduleId,
/******/ l: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.l = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // define getter function for harmony exports
/******/ __webpack_require__.d = function(exports, name, getter) {
/******/ if(!__webpack_require__.o(exports, name)) {
/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
/******/ }
/******/ };
/******/
/******/ // define __esModule on exports
/******/ __webpack_require__.r = function(exports) {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/
/******/ // create a fake namespace object
/******/ // mode & 1: value is a module id, require it
/******/ // mode & 2: merge all properties of value into the ns
/******/ // mode & 4: return value when already ns object
/******/ // mode & 8|1: behave like require
/******/ __webpack_require__.t = function(value, mode) {
/******/ if(mode & 1) value = __webpack_require__(value);
/******/ if(mode & 8) return value;
/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
/******/ var ns = Object.create(null);
/******/ __webpack_require__.r(ns);
/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
/******/ return ns;
/******/ };
/******/
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = function(module) {
/******/ var getter = module && module.__esModule ?
/******/ function getDefault() { return module['default']; } :
/******/ function getModuleExports() { return module; };
/******/ __webpack_require__.d(getter, 'a', getter);
/******/ return getter;
/******/ };
/******/
/******/ // Object.prototype.hasOwnProperty.call
/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(__webpack_require__.s = "../src/index.js");
/******/ })
/************************************************************************/
/******/ ({
/***/ "../src/index.js":
/*!***********************!*\
!*** ../src/index.js ***!
\***********************/
/*! no static exports found */
/***/ (function(module, exports) {
eval("function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }\n\nfunction _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }\n\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\nvar projectSite = 'https://affiliate.js.org/plugins/amazon';\n\nvar log = function log(isError) {\n if ((typeof console === \"undefined\" ? \"undefined\" : _typeof(console)) === 'object') {\n var args = Array.prototype.slice.call(arguments, 1);\n var logFunc = isError ? console.error : console.log;\n logFunc = Function.prototype.bind.call(logFunc, console);\n logFunc.apply(console, ['[AMZNPlugin] '].concat(args));\n }\n};\n\nvar Plugin = function Plugin(Affiliate, config) {\n var basic = {\n tags: {\n us: '',\n gb: '',\n de: '',\n fr: '',\n jp: '',\n ca: '',\n cn: '',\n it: '',\n es: '',\n \"in\": '',\n br: '',\n mx: ''\n },\n debug: false,\n locale: null,\n modifyDomain: true\n };\n if (config && config.tags) config.tags = _objectSpread({}, basic.tags, {}, config.tags);\n config = _objectSpread({}, basic, {}, config);\n if (config.debug) log(false, 'Read the docs at ' + projectSite);\n if (!config.tags.us) return log(true, 'Config must contain a US tag.');\n var tagList = {\n us: {\n tld: 'com',\n la: ['en']\n },\n gb: {\n tld: 'co.uk',\n la: ['gd', 'cy-ie', 'en-ie']\n },\n de: {\n tld: 'de',\n la: ['de']\n },\n fr: {\n tld: 'fr',\n la: ['fr']\n },\n jp: {\n tld: 'co.jp',\n la: ['jp']\n },\n ca: {\n tld: 'ca',\n la: []\n },\n cn: {\n tld: 'cn',\n la: ['zh', 'zh-hk', 'zh-tw']\n },\n it: {\n tld: 'it',\n la: ['it']\n },\n es: {\n tld: 'es',\n la: ['es']\n },\n \"in\": {\n tld: 'in',\n la: ['hi']\n },\n br: {\n tld: 'com.br',\n la: []\n },\n // issues?\n mx: {\n tld: 'com.mx',\n la: []\n }\n };\n\n for (var i in tagList) {\n var domain = 'amazon.' + tagList[i].tld;\n tagList[i].hosts = [domain, 'www.' + domain, 'smile.' + domain];\n }\n\n if (!config.locale) {\n var languages = window.navigator.languages.map(function (a) {\n return a.toLowerCase();\n });\n\n for (var _i in languages) {\n var cc = languages[_i].split('-')[1];\n\n for (var o in tagList) {\n if (o === cc || tagList[o].la.indexOf(languages[_i]) !== -1) {\n config.locale = o;\n break;\n }\n }\n\n if (config.locale) break;\n }\n } else {\n config.locale = config.locale.toLowerCase();\n }\n\n if (!config.tags[config.locale]) config.locale = 'us';\n if (config.debug) log(false, 'Locale set to \"' + config.locale + '\".');\n var hosts = [];\n\n for (var _i2 in tagList) {\n hosts = hosts.concat(tagList[_i2].hosts);\n }\n\n var affSettings = {\n tags: [{\n hosts: hosts,\n query: {\n tag: config.tags[config.locale]\n },\n modify: function modify(url) {\n var hasWWW = 0;\n if (url.hostname.substr(0, 3) === 'www') hasWWW = 1;\n url.set('hostname', tagList[config.locale].hosts[hasWWW]);\n return url;\n }\n }],\n log: config.debug\n };\n\n if (config.modifyDomain === false) {\n affSettings.tags = [];\n\n for (var _i3 in config.tags) {\n if (tagList[_i3] && config.tags[_i3]) {\n affSettings.tags.push({\n hosts: tagList[_i3].hosts,\n query: {\n tag: config.tags[_i3]\n }\n });\n }\n }\n }\n\n return Affiliate.create(affSettings);\n};\n\nmodule.exports = Plugin;\n\n//# sourceURL=webpack://AffiliatePluginAmazon/../src/index.js?");
/***/ })
/******/ });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.