function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; } // ==UserScript== // @name Steam Bundle Sites Extension // @namespace http://tampermonkey.net/ // @version 1.15.2 // @description A steam bundle sites' tool kits. // @icon http://store.steampowered.com/favicon.ico // @author Bisumaruko, Cloud // @include http*://store.steampowered.com/* // @include https://www.indiegala.com/gift* // @include https://www.indiegala.com/profile* // @include https://www.indiegala.com/game* // @include http*://*bundlestars.com/* // @include https://www.fanatical.com/* // @include https://www.humblebundle.com/downloads* // @include https://www.humblebundle.com/home/* // @include http*://*dailyindiegame.com/* // @include http*://bundle.ccyycn.com/order/* // @include https://groupees.com/purchases // @include https://groupees.com/profile/purchases/* // @include http*://*agiso.com/* // @require https://cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js // @require https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.9.2/sweetalert2.min.js // @resource sweetalert2CSS https://cdnjs.cloudflare.com/ajax/libs/limonte-sweetalert2/7.9.2/sweetalert2.min.css // @resource currencyFlags https://cdnjs.cloudflare.com/ajax/libs/currency-flags/1.5.0/currency-flags.min.css // @connect store.steampowered.com // @connect www.google.com // @connect www.google.com.tw // @connect www.google.com.au // @connect www.google.co.jp // @connect www.google.co.nz // @connect www.google.co.uk // @connect www.google.ca // @connect www.google.de // @connect www.google.it // @connect www.google.fr // @connect api.fanatical.com // @connect www.ecb.europa.eu // @grant GM_xmlhttpRequest // @grant GM_setValue // @grant GM_getValue // @grant GM_addStyle // @grant GM_getResourceText // @grant unsafeWindow // @run-at document-start // @noframes // @downloadURL none // ==/UserScript== /* global swal */ // setup jQuery const $ = jQuery.noConflict(true); $.fn.pop = [].pop; $.fn.shift = [].shift; // inject external css styles GM_addStyle(GM_getResourceText('sweetalert2CSS')); GM_addStyle(GM_getResourceText('currencyFlags')); // inject script css GM_addStyle(` pre.SBSE_errorMsg { height: 200px; text-align: left; white-space: pre-wrap; } `); // load up const regKey = /(?:(?:([A-Z0-9])(?!\1{4})){5}-){2,5}[A-Z0-9]{5}/g; const eol = "\r\n"; const has = Object.prototype.hasOwnProperty; const unique = a => [...new Set(a)]; const steam = JSON.parse(localStorage.getItem('SBSE_steam', '{}')); const activated = { data: JSON.parse(GM_getValue('SBSE_activated', '[]')), push(key) { this.data.push(key); GM_setValue('SBSE_activated', JSON.stringify(this.data)); }, check(key) { return this.data.includes(key); } }; const config = { data: JSON.parse(GM_getValue('SBSE_config', '{}')), set(key, value, callback = null) { this.data[key] = value; GM_setValue('SBSE_config', JSON.stringify(this.data)); if (typeof callback === 'function') callback(); }, get(key) { return has.call(this.data, key) ? this.data[key] : null; }, init() { if (!has.call(this.data, 'autoUpdateSessionID')) this.data.autoUpdateSessionID = true; if (!has.call(this.data, 'preselectIncludeTitle')) this.data.preselectIncludeTitle = false; if (!has.call(this.data, 'titleComesLast')) this.data.titleComesLast = false; if (!has.call(this.data, 'preselectJoinKeys')) this.data.preselectJoinKeys = false; if (!has.call(this.data, 'joinKeysASFStyle')) this.data.joinKeysASFStyle = true; if (!has.call(this.data, 'activateAllKeys')) this.data.activateAllKeys = false; } }; const keyDetails = { data: {}, set(key = '', obj) { if (key.length > 0) { obj.title = has.call(obj, 'title') ? obj.title.trim() : ''; if (has.call(obj, 'app')) obj.app = parseInt(obj.app, 10); if (has.call(obj, 'sub')) obj.sub = parseInt(obj.sub, 10); if (has.call(obj, 'url')) { const matched = obj.url.match(/steam.+\/(app|sub)\/(\d+)/); if (matched) obj[matched[1]] = parseInt(matched[2], 10); } this.data[key] = obj; } }, get(key) { return has.call(this.data, key) ? this.data[key] : null; }, isOwned(key) { const detail = this.data[key]; if (detail && steam.owned.app.includes(detail.app)) return true; if (detail && steam.owned.sub.includes(detail.sub)) return true; return false; } }; const ISO2 = { name: { tchinese: { AD: '安道爾', AE: '阿拉伯聯合大公國', AF: '阿富汗', AG: '安地卡及巴布達', AI: '安圭拉', AL: '阿爾巴尼亞', AM: '亞美尼亞', AO: '安哥拉', AQ: '南極洲', AR: '阿根廷', AS: '美屬薩摩亞', AT: '奧地利', AU: '澳大利亞', AW: '阿魯巴', AX: '奧蘭', AZ: '亞塞拜然', BA: '波士尼亞與赫塞哥維納', BB: '巴貝多', BD: '孟加拉', BE: '比利時', BF: '布吉納法索', BG: '保加利亞', BH: '巴林', BI: '蒲隆地', BJ: '貝南', BL: '聖巴泰勒米', BM: '百慕達', BN: '汶萊', BO: '玻利維亞', BQ: '波奈', BR: '巴西', BS: '巴哈馬', BT: '不丹', BV: '布威島', BW: '波札那', BY: '白俄羅斯', BZ: '貝里斯', CA: '加拿大', CC: '科科斯(基林)群島', CD: '剛果民主共和國', CF: '中非共和國', CG: '剛果共和國', CH: '瑞士', CI: '象牙海岸', CK: '庫克群島', CL: '智利', CM: '喀麥隆', CN: '中國', CO: '哥倫比亞', CR: '哥斯大黎加', CS: '塞爾維亞與蒙特內哥羅', CU: '古巴', CV: '維德角', CW: '古拉索', CX: '聖誕島', CY: '賽普勒斯', CZ: '捷克', DE: '德國', DJ: '吉布地', DK: '丹麥', DM: '多米尼克', DO: '多明尼加', DZ: '阿爾及利亞', EC: '厄瓜多', EE: '愛沙尼亞', EG: '埃及', EH: '西撒哈拉', ER: '厄利垂亞', ES: '西班牙', ET: '衣索比亞', FI: '芬蘭', FJ: '斐濟', FK: '福克蘭群島', FM: '密克羅尼西亞聯邦', FO: '法羅群島', FR: '法國', GA: '加彭', GB: '英國', GD: '格瑞那達', GE: '喬治亞', GF: '法屬圭亞那', GG: '根西', GH: '迦納', GI: '直布羅陀', GL: '格陵蘭', GM: '甘比亞', GN: '幾內亞', GP: '瓜德羅普', GQ: '赤道幾內亞', GR: '希臘', GS: '南喬治亞與南桑威奇', GT: '瓜地馬拉', GU: '關島', GW: '幾內亞比索', GY: '蓋亞那', HK: '香港', HM: '赫德島和麥克唐納群島', HN: '宏都拉斯', HR: '克羅埃西亞', HT: '海地', HU: '匈牙利', ID: '印尼', IE: '愛爾蘭', IL: '以色列', IM: '曼島', IN: '印度', IO: '英屬印度洋領地', IQ: '伊拉克', IR: '伊朗', IS: '冰島', IT: '義大利', JE: '澤西', JM: '牙買加', JO: '約旦', JP: '日本', KE: '肯亞', KG: '吉爾吉斯', KH: '柬埔寨', KI: '吉里巴斯', KM: '葛摩', KN: '聖克里斯多福及尼維斯', KP: '北韓', KR: '南韓', KW: '科威特', KY: '開曼群島', KZ: '哈薩克', LA: '寮國', LB: '黎巴嫩', LC: '聖露西亞', LI: '列支敦斯登', LK: '斯里蘭卡', LR: '賴比瑞亞', LS: '賴索托', LT: '立陶宛', LU: '盧森堡', LV: '拉脫維亞', LY: '利比亞', MA: '摩洛哥', MC: '摩納哥', MD: '摩爾多瓦', ME: '蒙特內哥羅', MF: '法屬聖馬丁', MG: '馬達加斯加', MH: '馬紹爾群島', MK: '馬其頓共和國', ML: '馬利', MM: '緬甸', MN: '蒙古', MO: '澳門', MP: '北馬里亞納群島', MQ: '馬丁尼克', MR: '茅利塔尼亞', MS: '蒙哲臘', MT: '馬爾他', MU: '模里西斯', MV: '馬爾地夫', MW: '馬拉威', MX: '墨西哥', MY: '馬來西亞', MZ: '莫三比克', NA: '納米比亞', NC: '新喀里多尼亞', NE: '尼日', NF: '諾福克島', NG: '奈及利亞', NI: '尼加拉瓜', NL: '荷蘭', NO: '挪威', NP: '尼泊爾', NR: '諾魯', NU: '紐埃', NZ: '紐西蘭', OM: '阿曼', PA: '巴拿馬', PE: '秘魯', PF: '法屬玻里尼西亞', PG: '巴布亞紐幾內亞', PH: '菲律賓', PK: '巴基斯坦', PL: '波瀾', PM: '聖皮耶與密克隆群島', PN: '皮特肯群島', PR: '波多黎各', PS: '巴勒斯坦', PT: '葡萄牙', PW: '帛琉', PY: '巴拉圭', QA: '卡達', RE: '留尼旺', RO: '羅馬尼亞', RS: '塞爾維亞', RU: '俄羅斯', RW: '盧安達', SA: '沙烏地阿拉伯', SB: '索羅門群島', SC: '塞席爾', SD: '蘇丹', SE: '瑞典', SG: '新加坡', SH: '聖赫勒拿、亞森欣與垂斯坦昆哈', SI: '斯洛維尼亞', SJ: '斯瓦巴和揚馬延', SK: '斯洛伐克', SL: '獅子山共和國', SM: '聖馬利諾', SN: '塞內加爾', SO: '索馬利亞', SR: '蘇利南', SS: '南蘇丹', ST: '聖多美普林西比', SV: '薩爾瓦多', SX: '荷屬聖馬丁', SY: '敘利亞', SZ: '史瓦濟蘭', TC: '土克凱可群島', TD: '查德', TF: '法屬南部和南極領地', TG: '多哥', TH: '泰國', TJ: '塔吉克', TK: '托克勞', TL: '東帝汶', TM: '土庫曼', TN: '突尼西亞', TO: '東加', TR: '土耳其', TT: '千里達及托巴哥', TV: '吐瓦魯', TW: '臺灣', TZ: '坦尚尼亞', UA: '烏克蘭', UG: '烏干達', UM: '美國本土外小島嶼', US: '美國', UY: '烏拉圭', UZ: '烏茲別克', VA: '聖座', VC: '聖文森及格瑞那丁', VE: '委內瑞拉', VG: '英屬維京群島', VI: '美屬維京群島', VN: '越南', VU: '萬那杜', WF: '瓦利斯和富圖納', WS: '薩摩亞', XK: '科索沃', YE: '葉門', YT: '馬約特', ZA: '南非', ZM: '尚比亞', ZW: '辛巴威' }, schinese: { AD: '安道尔', AE: '阿拉伯联合酋长国', AF: '阿富汗', AG: '安提瓜和巴布达', AI: '安圭拉', AL: '阿尔巴尼亚', AM: '亚美尼亚', AO: '安哥拉', AQ: '南极洲', AR: '阿根廷', AS: '美属萨摩亚', AT: '奥地利', AU: '澳大利亚', AW: '阿鲁巴', AX: '奥兰群岛', AZ: '阿塞拜疆', BA: '波斯尼亚和黑塞哥维那', BB: '巴巴多斯', BD: '孟加拉', BE: '比利时', BF: '布基纳法索', BG: '保加利亚', BH: '巴林', BI: '布隆迪', BJ: '贝宁', BL: '圣巴托洛缪岛', BM: '百慕大', BN: '文莱', BO: '玻利维亚', BQ: '博奈尔', BR: '巴西', BS: '巴哈马', BT: '不丹', BV: '布韦岛', BW: '博兹瓦纳', BY: '白俄罗斯', BZ: '伯利兹', CA: '加拿大', CC: '科科斯(基林)群岛', CD: '刚果(金)', CF: '中非共和国', CG: '刚果(布)', CH: '瑞士', CI: '科特迪瓦', CK: '库克群岛', CL: '智利', CM: '喀麦隆', CN: '中国', CO: '哥伦比亚', CR: '哥斯达黎加', CS: '塞尔维亚和黑山', CU: '古巴', CV: '佛得角', CW: '库拉索', CX: '圣诞岛', CY: '塞浦路斯', CZ: '捷克', DE: '德国', DJ: '吉布提', DK: '丹麦', DM: '多米尼克', DO: '多米尼加', DZ: '阿尔及利亚', EC: '厄瓜多尔', EE: '爱沙尼亚', EG: '埃及', EH: '西撒哈拉', ER: '厄立特里亚', ES: '西班牙', ET: '埃塞俄比亚', FI: '芬兰', FJ: '斐济', FK: '福克兰群岛', FM: '密克罗尼西亚', FO: '法罗群岛', FR: '法国', GA: '加蓬', GB: '英国', GD: '格林纳达', GE: '格鲁吉亚', GF: '法属圭亚那', GG: '根西', GH: '加纳', GI: '直布罗陀', GL: '格陵兰', GM: '冈比亚', GN: '几内亚', GP: '瓜德鲁普', GQ: '赤道几内亚', GR: '希腊', GS: '南乔治亚岛和南桑威奇群岛', GT: '危地马拉', GU: '关岛', GW: '几内亚比绍', GY: '圭亚那', HK: '香港', HM: '赫德岛和麦克唐纳群岛', HN: '洪都拉斯', HR: '克罗地亚', HT: '海地', HU: '匈牙利', ID: '印尼', IE: '爱尔兰', IL: '以色列', IM: '马恩岛', IN: '印度', IO: '英属印度洋领地', IQ: '伊拉克', IR: '伊朗', IS: '冰岛', IT: '意大利', JE: '泽西岛', JM: '牙买加', JO: '约旦', JP: '日本', KE: '肯尼亚', KG: '吉尔吉斯', KH: '柬埔寨', KI: '基里巴斯', KM: '科摩罗', KN: '圣基茨和尼维斯', KP: '朝鲜', KR: '韩国', KW: '科威特', KY: '开曼群岛', KZ: '哈萨克斯坦', LA: '老挝', LB: '黎巴嫩', LC: '圣卢西亚', LI: '列支敦士登', LK: '斯里兰卡', LR: '利比里亚', LS: '莱索托', LT: '立陶宛', LU: '卢森堡', LV: '拉脱维亚', LY: '利比亚', MA: '摩洛哥', MC: '摩纳哥', MD: '摩尔多瓦', ME: '黑山', MF: '法属圣马丁', MG: '马达加斯加', MH: '马绍尔群岛', MK: '马其顿', ML: '马里', MM: '缅甸', MN: '蒙古', MO: '澳门', MP: '北马里亚纳群岛', MQ: '马提尼克', MR: '毛里塔尼亚', MS: '蒙塞拉特', MT: '马耳他', MU: '毛里求斯', MV: '马尔代夫', MW: '马拉维', MX: '墨西哥', MY: '马来西亚', MZ: '莫桑比克', NA: '纳米比亚', NC: '新喀里多尼亚', NE: '尼日尔', NF: '诺福克岛', NG: '尼日利', NI: '尼加拉瓜', NL: '荷兰', NO: '挪威', NP: '尼泊尔', NR: '瑙鲁', NU: '纽埃', NZ: '新西兰', OM: '阿曼', PA: '巴拿马', PE: '秘鲁', PF: '法属波利尼西亚a', PG: '巴布亚新几内亚', PH: '菲律宾', PK: '巴基斯坦', PL: '波兰', PM: '圣皮埃尔和密克隆', PN: '皮特凯恩群岛', PR: '波多黎各', PS: '巴勒斯坦', PT: '葡萄牙', PW: '帕劳', PY: '巴拉圭', QA: '卡塔尔', RE: '留尼旺島', RO: '罗马尼亚', RS: '塞尔维亚', RU: '俄罗斯', RW: '卢旺达', SA: '沙特阿拉伯', SB: '所罗门群岛', SC: '塞舌尔', SD: '苏丹', SE: '瑞典', SG: '新加坡', SH: '圣赫勒拿、阿森松与特斯坦达库尼亚', SI: '斯洛文尼', SJ: '斯瓦尔巴群岛和扬马延岛', SK: '斯洛伐克', SL: '塞拉利昂', SM: '圣马力诺', SN: '塞内加尔', SO: '索马里', SR: '苏里南', SS: '南苏丹', ST: '圣多美和普林西比', SV: '萨尔瓦多', SX: '荷属圣马丁', SY: '叙利亚', SZ: '斯威士兰', TC: '特克斯和凯科斯群岛', TD: '乍得', TF: '法属南部领土', TG: '多哥', TH: '泰国', TJ: '塔吉克斯坦', TK: '托克劳', TL: '东帝汶', TM: '土库曼斯坦', TN: '突尼斯', TO: '汤加', TR: '土耳其', TT: '特立尼达和多巴哥', TV: '图瓦卢', TW: '台湾', TZ: '坦桑尼亚', UA: '乌克兰', UG: '乌干达', UM: '美国本土外小岛屿', US: '美国', UY: '乌拉圭', UZ: '乌兹别克斯坦', VA: '圣座', VC: '圣文森特和格林纳丁斯', VE: '委内瑞拉', VG: '英属维尔京群岛', VI: '美属维尔京群岛', VN: '越南', VU: '瓦努阿图', WF: '瓦利斯和富图纳群岛', WS: '萨摩亚', XK: '科索沃', YE: '也门', YT: '马约特', ZA: '南非', ZM: '赞比亚', ZW: '津巴布韦' }, english: { AD: 'Andorra', AE: 'United Arab Emirates', AF: 'Afghanistan', AG: 'Antigua and Barbuda', AI: 'Anguilla', AL: 'Albania', AM: 'Armenia', AO: 'Angola', AQ: 'Antarctica', AR: 'Argentina', AS: 'American Samoa', AT: 'Austria', AU: 'Australia', AW: 'Aruba', AX: 'Aland Islands', AZ: 'Azerbaijan', BA: 'Bosnia and Herzegovina', BB: 'Barbados', BD: 'Bangladesh', BE: 'Belgium', BF: 'Burkina Faso', BG: 'Bulgaria', BH: 'Bahrain', BI: 'Burundi', BJ: 'Benin', BL: 'Saint Barthélemy', BM: 'Bermuda', BN: 'Brunei', BO: 'Bolivia', BQ: 'Bonaire', BR: 'Brazil', BS: 'Bahamas', BT: 'Bhutan', BV: 'Bouvet Island', BW: 'Botswana', BY: 'Belarus', BZ: 'Belize', CA: 'Canada', CC: 'Cocos (Keeling) Islands', CD: 'East Congo', CF: 'Central African Republic', CG: 'West Congo', CH: 'Switzerland', CI: 'Ivory Coast', CK: 'Cook Islands', CL: 'Chile', CM: 'Cameroon', CN: 'China', CO: 'Colombia', CR: 'Costa Rica', CS: 'Serbia and Montenegro', CU: 'Cuba', CV: 'Cabo Verde', CW: 'Curaçao', CX: 'Christmas Island', CY: 'Cyprus', CZ: 'Czechia', DE: 'Germany', DJ: 'Djibouti', DK: 'Denmark', DM: 'Dominica', DO: 'Dominican Republic', DZ: 'Algeria', EC: 'Ecuador', EE: 'Estonia', EG: 'Egypt', EH: 'Western Sahara', ER: 'Eritrea', ES: 'Spain', ET: 'Ethiopia', FI: 'Finland', FJ: 'Fiji', FK: 'Falkland Islands', FM: 'Micronesia', FO: 'Faroe Islands', FR: 'France', GA: 'Gabon', GB: 'United Kingdom', GD: 'Grenada', GE: 'Georgia', GF: 'French Guiana', GG: 'Guernsey', GH: 'Ghana', GI: 'Gibraltar', GL: 'Greenland', GM: 'Gambia', GN: 'Guinea', GP: 'Guadeloupe', GQ: 'Equatorial Guinea', GR: 'Greece', GS: 'South Georgia and the South Sandwich Islands', GT: 'Guatemala', GU: 'Guam', GW: 'Guinea-Bissau', GY: 'Guyana', HK: 'Hong Kong', HM: 'Heard Island and McDonald Islands', HN: 'Honduras', HR: 'Croatia', HT: 'Haiti', HU: 'Hungary', ID: 'Indonesia', IE: 'Ireland', IL: 'Israel', IM: 'Isle of Man', IN: 'India', IO: 'British Indian Ocean Territory', IQ: 'Iraq', IR: 'Iran', IS: 'Iceland', IT: 'Italy', JE: 'Jersey', JM: 'Jamaica', JO: 'Jordan', JP: 'Japan', KE: 'Kenya', KG: 'Kyrgyzstan', KH: 'Cambodia', KI: 'Kiribati', KM: 'Comoros', KN: 'Saint Kitts and Nevis', KP: 'North Korea', KR: 'South Korea', KW: 'Kuwait', KY: 'Cayman Islands', KZ: 'Kazakhstan', LA: 'Lao', LB: 'Lebanon', LC: 'Saint Lucia', LI: 'Liechtenstein', LK: 'Sri Lanka', LR: 'Liberia', LS: 'Lesotho', LT: 'Lithuania', LU: 'Luxembourg', LV: 'Latvia', LY: 'Libya', MA: 'Morocco', MC: 'Monaco', MD: 'Moldova', ME: 'Montenegro', MF: 'Saint Martin (French part)', MG: 'Madagascar', MH: 'Marshall Islands', MK: 'Macedonia', ML: 'Mali', MM: 'Myanmar', MN: 'Mongolia', MO: 'Macao', MP: 'Northern Mariana Islands', MQ: 'Martinique', MR: 'Mauritania', MS: 'Montserrat', MT: 'Malta', MU: 'Mauritius', MV: 'Maldives', MW: 'Malawi', MX: 'Mexico', MY: 'Malaysia', MZ: 'Mozambique', NA: 'Namibia', NC: 'New Caledonia', NE: 'Niger', NF: 'Norfolk Island', NG: 'Nigeria', NI: 'Nicaragua', NL: 'Netherlands', NO: 'Norway', NP: 'Nepal', NR: 'Nauru', NU: 'Niue', NZ: 'New Zealand', OM: 'Oman', PA: 'Panama', PE: 'Peru', PF: 'French Polynesia', PG: 'Papua New Guinea', PH: 'Philippines', PK: 'Pakistan', PL: 'Poland', PM: 'Saint Pierre and Miquelon', PN: 'Pitcairn', PR: 'Puerto Rico', PS: 'Palestine', PT: 'Portugal', PW: 'Palau', PY: 'Paraguay', QA: 'Qatar', RE: 'Reunion', RO: 'Romania', RS: 'Serbia', RU: 'Russia', RW: 'Rwanda', SA: 'Saudi Arabia', SB: 'Solomon Islands', SC: 'Seychelles', SD: 'Sudan', SE: 'Sweden', SG: 'Singapore', SH: 'Saint Helena, Ascension and Tristan da Cunha', SI: 'Slovenia', SJ: 'Svalbard and Jan Mayen', SK: 'Slovakia', SL: 'Sierra Leone', SM: 'San Marino', SN: 'Senegal', SO: 'Somalia', SR: 'Suriname', SS: 'South Sudan', ST: 'Sao Tome and Principe', SV: 'El Salvador', SX: 'Sint Maarten (Dutch part)', SY: 'Syria', SZ: 'Swaziland', TC: 'Turks and Caicos Islands', TD: 'Chad', TF: 'French Southern Territories', TG: 'Togo', TH: 'Thailand', TJ: 'Tajikistan', TK: 'Tokelau', TL: 'Timor-Leste', TM: 'Turkmenistan', TN: 'Tunisia', TO: 'Tonga', TR: 'Turkey', TT: 'Trinidad and Tobago', TV: 'Tuvalu', TW: 'Taiwan', TZ: 'Tanzania', UA: 'Ukraine', UG: 'Uganda', UM: 'United States Minor Outlying Islands', US: 'United States', UY: 'Uruguay', UZ: 'Uzbekistan', VA: 'Holy See', VC: 'Saint Vincent and the Grenadines', VE: 'Venezuela', VG: 'Virgin Islands, British', VI: 'Virgin Islands, U.S.', VN: 'Viet Nam', VU: 'Vanuatu', WF: 'Wallis and Futuna', WS: 'Samoa', XK: 'Kosovo', YE: 'Yemen', YT: 'Mayotte', ZA: 'South Africa', ZM: 'Zambia', ZW: 'Zimbabwe' } }, get(code, language) { const data = this.name[language || config.get('language') || 'english']; return has.call(data, code) ? data[code] : code; } }; const xe = { exchangeRate: JSON.parse(GM_getValue('SBSE_xe', '{}')), currencies: { AUD: { english: 'Australian Dollar', tchinese: '澳幣', schinese: '澳元', symbol: 'AU$' }, CAD: { english: 'Canadian Dollar', tchinese: '加幣', schinese: '加元', symbol: 'CA$' }, CNY: { english: 'Chinese Yuan', tchinese: '人民幣', schinese: '人民币', symbol: 'CN¥' }, EUR: { english: 'Euro', tchinese: '歐元', schinese: '欧元', symbol: '€' }, GBP: { english: 'Great Britain Pound', tchinese: '英鎊', schinese: '英镑', symbol: '£' }, HKD: { english: 'Hong Kong Dollar', tchinese: '港幣', schinese: '港元', symbol: 'HK$' }, JPY: { english: 'Japanese Yen', tchinese: '日圓', schinese: '日元', symbol: 'JP¥' }, KRW: { english: 'South Korean Won', tchinese: '韓圓', schinese: '韩币', symbol: '₩' }, MYR: { english: 'Malaysian Ringgit', tchinese: '令吉', schinese: '林吉特', symbol: 'RM' }, NTD: { english: 'New Taiwan Dollar', tchinese: '台幣', schinese: '台币', symbol: 'NT$' }, NZD: { english: 'New Zealand Dollar', tchinese: '紐幣', schinese: '新西兰元', symbol: 'NZ$' }, RUB: { english: 'Russian Ruble', tchinese: '盧布', schinese: '卢布', symbol: 'руб' }, USD: { english: 'United States Dollar', tchinese: '美元', schinese: '美元', symbol: 'US$' } }, get() { const self = this; GM_xmlhttpRequest({ method: 'GET', url: 'http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml', onload: res => { if (res.status === 200) { try { const exchangeRate = { lastUpdate: Date.now(), rates: {} }; res.response.split("\n").forEach(line => { if (line.includes('currency=')) { const currency = line.split('currency=\'').pop().slice(0, 3); const rate = line.trim().split('rate=\'').pop().slice(0, -3); exchangeRate.rates[currency] = parseFloat(rate); } }); // get NTD GM_xmlhttpRequest({ method: 'GET', url: 'https://www.google.com/search?q=1+EUR+%3D+NTD', onload: searchRes => { const rate = parseFloat(searchRes.response.split('
${text.settingsAutoUpdateSessionID} | |
${text.settingsSessionID} | |
${text.settingsSyncLibrary} | |
${text.settingsLanguage} | |
${text.settingsPreselectIncludeTitle} | |
${text.settingsTitleComesLast} | |
${text.settingsPreselectJoinKeys} | |
${text.settingsJoinKeysASFStyle} | |
${text.settingsActivateAllKeys} |
'); errorMsg.push(`sessionID: ${config.get('sessionID') + eol}`); errorMsg.push(`autoUpdate: ${config.get('autoUpdateSessionID') + eol}`); errorMsg.push(`status: ${res.status + eol}`); errorMsg.push(`response: ${res.response + eol}`); errorMsg.push(''); swal({ title: text.failTitle, html: text.failDetailRequestFailedNeedUpdate + eol + errorMsg.join(''), type: 'error' }); getSessionID(); callback(); } } }); } } else callback(); }, activateKeys(input, callback) { const self = this; const keys = unique(input.match(regKey)); if (keys.length > 0) { keys.forEach(key => { self.results[key] = [key]; }); self.keys = Object.keys(self.results); self.updateResults(); self.activateKey(callback); } else { self.updateResults(text.emptyInput); callback(); } } }; const bundleSitesBoxHandler = { reveal(handler, $games) { const $reveal = $('.SBSE_BtnReveal'); $reveal.addClass('working'); handler($games, () => { $reveal.removeClass('working'); $('.SBSE_BtnRetrieve').click(); }); }, retrieve(data) { if (data.length > 0) { const includeTitle = !!$('.SBSE_ChkTitle:checked').length; const joinKeys = !!$('.SBSE_ChkJoin:checked').length; const separator = joinKeys ? ',' : eol; const prefix = joinKeys && config.get('joinKeysASFStyle') ? '!redeem ' : ''; const keys = []; data.forEach(d => { if (typeof d === 'string') { keys.push(d); } else { const temp = [d.key]; if (includeTitle) temp.unshift(d.title); if (config.get('titleComesLast')) temp.reverse(); keys.push(temp.join(', ')); } }); $('.SBSE_container > textarea').val(prefix + keys.join(separator)); } }, activate(e) { const $self = $(e.delegateTarget); const $textarea = $('.SBSE_container > textarea'); let input = $textarea.val().trim(); if (input.length === 0) { $('.SBSE_BtnRetrieve').click(); input = $textarea.val(); } $self.prop('disabled', true).addClass('working'); $textarea.attr('disabled', ''); activateHandler.activateKeys(input, () => { $self.prop('disabled', false).removeClass('working'); $textarea.removeAttr('disabled'); }); }, copy() { $('.SBSE_container > textarea').select(); document.execCommand('copy'); }, reset() { $('.SBSE_container > textarea').val(''); }, export(data, title) { // data: [{key: ..., title: ...}, ...] const $export = $('.SBSE_BtnExport'); $export.removeAttr('href').removeAttr('download'); if (Array.isArray(data) && data.length > 0) { const filename = title.replace(/[\\/:*?"<>|!]/g, ''); const formattedData = data.map(line => `${line.title.replace(/,/g, ' ')},${line.key}`).join(eol); $export.attr('href', `data:text/csv;charset=utf-8,\ufeff${encodeURIComponent(formattedData)}`).attr('download', `${filename}.csv`); } }, settings() { settings.display(); } }; const bundleSitesBox = () => { GM_addStyle(` .SBSE_container { width: 100%; height: 200px; display: flex; flex-direction: column; box-sizing: border-box; } .SBSE_container > textarea { width: 100%; height: 150px; padding: 5px; border: none; box-sizing: border-box; resize: none; outline: none; } .SBSE_container > div { width: 100%; padding-top: 5px; box-sizing: border-box; } .SBSE_container > div > button, .SBSE_container > div > a { width: 120px; position: relative; margin-right: 10px; line-height: 28px; box-sizing: border-box; outline: none; cursor: pointer; transition: all 0.5s; } .SBSE_container > div > a { display: inline-block; text-align: center; } .SBSE_container label { margin-right: 10px; } #SBSE_BtnSettings { width: 20px; height: 20px; float: right; margin-top: 3px; margin-right: 0; margin-left: 10px; background-color: transparent; background-image: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/PjwhRE9DVFlQRSBzdmcgIFBVQkxJQyAnLS8vVzNDLy9EVEQgU1ZHIDEuMS8vRU4nICAnaHR0cDovL3d3dy53My5vcmcvR3JhcGhpY3MvU1ZHLzEuMS9EVEQvc3ZnMTEuZHRkJz48c3ZnIGhlaWdodD0iMzJweCIgc3R5bGU9ImVuYWJsZS1iYWNrZ3JvdW5kOm5ldyAwIDAgMzIgMzI7IiB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAzMiAzMiIgd2lkdGg9IjMycHgiIHhtbDpzcGFjZT0icHJlc2VydmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxnIGlkPSJMYXllcl8xIi8+PGcgaWQ9ImNvZyI+PHBhdGggZD0iTTMyLDE3Ljk2OXYtNGwtNC43ODEtMS45OTJjLTAuMTMzLTAuMzc1LTAuMjczLTAuNzM4LTAuNDQ1LTEuMDk0bDEuOTMtNC44MDVMMjUuODc1LDMuMjUgICBsLTQuNzYyLDEuOTYxYy0wLjM2My0wLjE3Ni0wLjczNC0wLjMyNC0xLjExNy0wLjQ2MUwxNy45NjksMGgtNGwtMS45NzcsNC43MzRjLTAuMzk4LDAuMTQxLTAuNzgxLDAuMjg5LTEuMTYsMC40NjlsLTQuNzU0LTEuOTEgICBMMy4yNSw2LjEyMWwxLjkzOCw0LjcxMUM1LDExLjIxOSw0Ljg0OCwxMS42MTMsNC43MDMsMTIuMDJMMCwxNC4wMzF2NGw0LjcwNywxLjk2MWMwLjE0NSwwLjQwNiwwLjMwMSwwLjgwMSwwLjQ4OCwxLjE4OCAgIGwtMS45MDIsNC43NDJsMi44MjgsMi44MjhsNC43MjMtMS45NDVjMC4zNzksMC4xOCwwLjc2NiwwLjMyNCwxLjE2NCwwLjQ2MUwxNC4wMzEsMzJoNGwxLjk4LTQuNzU4ICAgYzAuMzc5LTAuMTQxLDAuNzU0LTAuMjg5LDEuMTEzLTAuNDYxbDQuNzk3LDEuOTIybDIuODI4LTIuODI4bC0xLjk2OS00Ljc3M2MwLjE2OC0wLjM1OSwwLjMwNS0wLjcyMywwLjQzOC0xLjA5NEwzMiwxNy45Njl6ICAgIE0xNS45NjksMjJjLTMuMzEyLDAtNi0yLjY4OC02LTZzMi42ODgtNiw2LTZzNiwyLjY4OCw2LDZTMTkuMjgxLDIyLDE1Ljk2OSwyMnoiIHN0eWxlPSJmaWxsOiM0RTRFNTA7Ii8+PC9nPjwvc3ZnPg==); background-size: contain; background-repeat: no-repeat; background-origin: border-box; border: none; vertical-align: top; } `); // spinner button affect GM_addStyle(` .SBSE_container > div > button:before { content: ''; position: absolute; margin-top: 5px; right: 10px; width: 20px; height: 20px; border: 3px solid; border-left-color: transparent; border-radius: 50%; box-sizing: border-box; opacity: 0; transition: opacity 0.5s; animation-duration: 1s; animation-iteration-count: infinite; animation-name: rotate; animation-timing-function: linear; } .SBSE_container > div > button.narrow.working { width: 100px; padding-right: 40px; transition: all 0.5s; } .SBSE_container > div > button.working:before { transition-delay: 0.5s; transition-duration: 1s; opacity: 1; } @keyframes rotate { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } } `); const $container = $(` `); // bind event $container.find('.SBSE_BtnCopy').click(bundleSitesBoxHandler.copy); $container.find('.SBSE_BtnReset').click(bundleSitesBoxHandler.reset); $container.find('.SBSE_BtnActivate').click(bundleSitesBoxHandler.activate); $container.find('#SBSE_BtnSettings').click(bundleSitesBoxHandler.settings); // apply settings if (config.get('preselectIncludeTitle')) $container.find('.SBSE_ChkTitle').prop('checked', true); if (config.get('preselectJoinKeys')) $container.find('.SBSE_ChkJoin').prop('checked', true); return $container; }; const siteHandlers = { indiegala() { const $box = bundleSitesBox(); // insert textarea $('#library-contain').eq(0).before($box); // support for new password protected gift page const $node = $('#gift-contents'); if ($node.length > 0) { const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { Array.from(mutation.addedNodes).forEach(addedNode => { if (addedNode.id === 'library-contain') { $node.prepend($box); observer.disconnect(); } }); }); }); observer.observe($node[0], { childList: true }); } // inject css GM_addStyle(` .SBSE_container { margin-top: 10px; } .SBSE_container > textarea { border: 1px solid #CC001D; border-radius: 3px; } .SBSE_container > div > button, .SBSE_container > div > a { width: 100px; background-color: #CC001D; color: white; border-radius: 3px; } .SBSE_container > div > a:hover { color: white; } `); // dom source const source = location.pathname === '/profile' ? 'div[id*="_sale_"].collapse.in' : document; const extractKeys = () => { const keys = []; $(source).find('.game-key-string').each((index, element) => { const $ele = $(element); const key = $ele.find('.keys').val(); if (key) { const $a = $ele.find('.title_game > a'); const title = $a.text().trim(); // append key details keyDetails.set(key, { url: $a.attr('href'), title: $a.text() }); keys.push({ key, title }); } }); return keys; }; // button click $box.find('.SBSE_BtnReveal').click(() => { const handler = ($games, callback) => { const game = $games.shift(); if (game) { const $game = $(game); const code = $game.attr('id').split('_').pop(); const id = $game.attr('onclick').match(/steampowered\.com\/(app|sub)\/(\d+)/)[2]; $.ajax({ method: 'GET', url: '/myserials/syncget', dataType: 'json', data: { code, cache: false, productId: id }, beforeSend() { $(`#permbutton_${code}, #fetchlink_${code}, #info_key_${code}`).hide(); $(`#fetching_${code}`).fadeIn(); $(`#ajax_loader_${code}`).show(); $(`#container_activate_${code}`).html(''); }, success(data) { $(`#ajax_loader_${code}, #fetching_${code}, #info_key_${code}`).hide(); $(`#serial_${code}`).fadeIn(); $(`#serial_n_${code}`).val(data.serial_number); $game.parent().prev().find('.btn-convert-to-trade').remove(); handler($games, callback); }, error() { swal(text.failTitle, text.failDetailUnexpected, 'error'); } }); } else callback(); }; bundleSitesBoxHandler.reveal(handler, $(source).find('a[id^=fetchlink_]')); }); $box.find('.SBSE_BtnRetrieve').click(() => { bundleSitesBoxHandler.retrieve(extractKeys()); }); $box.find('.SBSE_BtnExport').click(() => { const $bundleTitle = location.pathname === '/profile' ? $('[aria-expanded="true"] > div#bundle-title') : $('#bundle-title, #indie_gala_2 > div > span'); const title = `IndieGala ${$bundleTitle.length > 0 ? $bundleTitle.text() : 'Keys'}`; bundleSitesBoxHandler.export(extractKeys(), title); }); }, fanatical() { let APIData = null; const fetchAPIData = (() => { var _ref = _asyncToGenerator(function* (s, c) { let slug = s; let callback = c; if (typeof s === 'function') { callback = s; slug = location.href.split('/').pop(); } let JSONString = GM_getValue(`Fanatical-${slug}`, ''); if (JSONString.length === 0) { const res = yield fetch(`https://api.fanatical.com/api/products/${slug}`); if (res.ok) { JSONString = yield res.text(); GM_setValue(`Fanatical-${slug}`, JSONString); } else JSONString = '{}'; } APIData = JSON.parse(JSONString); if (typeof callback === 'function') callback(); }); return function fetchAPIData(_x, _x2) { return _ref.apply(this, arguments); }; })(); const extractKeys = () => { const keys = []; $('.account-content dl:has(input)').each((index, dl) => { const $dl = $(dl); const key = $(dl).find('input').val(); const title = $dl.attr('data-title') || $dl.find('dd').eq(1).text().trim(); const app = $dl.attr('data-appID'); // append key details if (app.length > 0) { keyDetails.set(key, { title, app }); } keys.push({ key, title }); }); return keys; }; const insertBox = () => { const $anchor = $('h3:contains(Order Keys)'); if ($('.SBSE_container').length === 0 && $anchor.length > 0) { // insert textarea $anchor.eq(0).before(bundleSitesBox()); // inject css GM_addStyle(` .SBSE_container { margin-top: 10px; } .SBSE_container > textarea { background-color: #434343; color: #eee; } .SBSE_container > div > button, .SBSE_container > div > a { width: 80px; } .SBSE_container > div > button, .SBSE_container select, .SBSE_container > div > a { border: 1px solid transparent; background-color: #1c1c1c; color: #eee; } .SBSE_container > div > button:hover, .SBSE_container select:hover, .SBSE_container > div > a:hover { color: #A8A8A8; } .SBSE_container > div > a { text-decoration: none; } .SBSE_container label { color: #DEDEDE; } .SBSE_container select { max-width:120px; height: 30px; } .SBSE_container select, .SBSE_container span { margin-right: 0; margin-left: 10px; float: right; } .SBSE_container span { margin-top: 5px; } `); // narrow buttons $('.SBSE_container > div > button').addClass('narrow'); // dodge from master css selector $('.SBSE_container > div > a').attr('href', ''); /* // insert bundlestars select $('.SBSE_container > div').append(` ${text.selectConnector} `); */ // button click $('.SBSE_BtnReveal').click(() => { const handler = ($games, callback) => { const game = $games.shift(); if (game) { game.click(); setTimeout(handler.bind(null, $games, callback), 300); } else setTimeout(callback, 500); }; bundleSitesBoxHandler.reveal(handler, $('.account-content dl button')); }); $('.SBSE_BtnRetrieve').click(() => { bundleSitesBoxHandler.retrieve(extractKeys()); }); $('.SBSE_BtnExport').click(() => { const $bundleTitle = $('h5'); const title = `Fanatical - ${$bundleTitle.length > 0 ? $bundleTitle.text() : 'Keys'}`; bundleSitesBoxHandler.export(extractKeys(), title); }); // append Steam ID const observer = new MutationObserver(mutations => { mutations.forEach(mutation => { Array.from(mutation.addedNodes).forEach(addedNode => { const title = $(addedNode).find('h5').eq(0).text(); const slug = title.trim().toLowerCase().replace(/ /g, '-'); if (slug.length > 0) { observer.disconnect(); fetchAPIData(slug, () => { if (Object.keys(APIData).length > 0) { const matchGame = data => { if (has.call(data, 'steam') && data.steam.id) { const $gameTitle = $(`dd > div.d-flex.flex-column:contains(${data.name})`); $gameTitle.contents().filter((i, n) => n.nodeType === 3).wrap(``); $gameTitle.closest('dl').attr({ 'data-title': data.name, 'data-appID': data.steam.id }); } }; matchGame(APIData); APIData.bundles.forEach(tier => { tier.games.forEach(matchGame); }); } }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); } }; const productHandler = () => { if (Object.keys(APIData).length > 0) { GM_addStyle(` .cardBlock { width: 100%; padding: 0 .875rem 0 .875rem; } .cardBlock > div { padding: 1rem; } .cardBlock .currencyToggler { width: 100%; height: 40px; margin-bottom: 10px; font-size: 20px; border-radius: 3px; } .starDeal { padding: 1rem; } .starDeal > div { display: flex; align-items: center; justify-content: space-evenly; } .starDeal .currencyToggler { width: 300px; height: 40px; font-size: 20px; border-radius: 3px; } .pricingDetail { background-color: transparent; } .pricingDetail th { padding-top: 10px; } .pricingDetail .cheapest { border-bottom: 1px solid #ff9800; font-weight: bold; } .pricingDetail .currency-flag { vertical-align: text-bottom; } `); const language = config.get('language'); const $priceExt = $(`
${text.HBDisallowedCountries}
${disallowed.join(separator)}
${text.HBExclusiveCountries}
${exclusive.join(separator)}