/* README๏ผšhttps://github.com/yichahucha/surge/tree/master */ const $tool = new Tool() const consoleLog = false; const imdbApikeyCacheKey = "ImdbApikeyCacheKey"; const netflixTitleCacheKey = "NetflixTitleCacheKey"; if (!$tool.isResponse) { let url = $request.url; const urlDecode = decodeURIComponent(url); const videos = urlDecode.match(/"videos","(\d+)"/); const videoID = videos[1]; const map = getTitleMap(); const title = map[videoID]; const isEnglish = url.match(/languages=en/) ? true : false; if (!title && !isEnglish) { const currentSummary = urlDecode.match(/\["videos","(\d+)","current","summary"\]/); if (currentSummary) { url = url.replace("&path=" + encodeURIComponent(currentSummary[0]), ""); } url = url.replace(/&languages=(.*?)&/, "&languages=en-US&"); } url += "&path=" + encodeURIComponent(`[${videos[0]},"details"]`); $done({ url }); } else { var IMDbApikeys = IMDbApikeys(); var IMDbApikey = $tool.read(imdbApikeyCacheKey); if (!IMDbApikey) updateIMDbApikey(); let obj = JSON.parse($response.body); if (consoleLog) console.log("Netflix Original Body:\n" + $response.body); if (typeof (obj.paths[0][1]) == "string") { const videoID = obj.paths[0][1]; const video = obj.value.videos[videoID]; const map = getTitleMap(); let title = map[videoID]; if (!title) { title = video.summary.title; setTitleMap(videoID, title, map); } let year = null; let type = video.summary.type; if (type == "show") { type = "series"; } if (video.details) { if (type == "movie") { year = video.details.releaseYear; } delete video.details; } const requestRatings = async () => { const IMDb = await requestIMDbRating(title, year, type); const Douban = await requestDoubanRating(IMDb.id); const IMDbrating = IMDb.msg.rating; const tomatoes = IMDb.msg.tomatoes; const country = IMDb.msg.country; const awards = IMDb.msg.awards; const doubanRating = Douban.rating; const message = `${awards.length > 0 ? awards + "\n": ""}${country}\n${IMDbrating}\n${doubanRating}${tomatoes.length > 0 ? "\n" + tomatoes + "\n" : "\n"}`; return message; } let msg = ""; requestRatings() .then(message => msg = message) .catch(error => msg = error + "\n") .finally(() => { let summary = obj.value.videos[videoID].summary; summary["supplementalMessage"] = `${msg}${summary && summary.supplementalMessage ? "\n" + summary.supplementalMessage : ""}`; msg_obj = {"tagline":summary.supplementalMessage, "classification":"REGULAR"} if (summary["supplementalMessages"]) { summary["supplementalMessages"].push(msg_obj) }else { summary["supplementalMessages"] = [msg_obj] } if (consoleLog) console.log("Netflix Modified Body:\n" + JSON.stringify(obj)); $done({ body: JSON.stringify(obj) }); }); } else { $done({}); } } function getTitleMap() { const map = $tool.read(netflixTitleCacheKey); return map ? JSON.parse(map) : {}; } function setTitleMap(id, title, map) { map[id] = title; $tool.write(JSON.stringify(map), netflixTitleCacheKey); } function requestDoubanRating(imdbId) { return new Promise(function (resolve, reject) { const url = `https://www.douban.com/search?cat=1002&q=${imdbId}`; if (consoleLog) console.log("Netflix Douban Rating URL:\n" + url); $tool.get(url, function (error, response, data) { if (!error) { if (consoleLog) console.log("Netflix Douban Rating Data:\n" + data); if (response.status == 200) { const rating = get_douban_rating_message(data); resolve({ rating }); } else { resolve({ rating: "Douban: " + errorTip().noData }); } } else { if (consoleLog) console.log("Netflix Douban Rating Error:\n" + error); resolve({ rating: "Douban: " + errorTip().error }); } }); }); } function requestIMDbRating(title, year, type) { return new Promise(function (resolve, reject) { let url = "https://www.omdbapi.com/?t=" + encodeURI(title) + "&apikey=" + IMDbApikey; if (year) url += "&y=" + year; if (type) url += "&type=" + type; if (consoleLog) console.log("Netflix IMDb Rating URL:\n" + url); $tool.get(url, function (error, response, data) { if (!error) { if (consoleLog) console.log("Netflix IMDb Rating Data:\n" + data); if (response.status == 200) { const obj = JSON.parse(data); if (obj.Response != "False") { const id = obj.imdbID; const msg = get_IMDb_message(obj); resolve({ id, msg }); } else { reject(errorTip().noData); } } else if (response.status == 401) { if (IMDbApikeys.length > 1) { updateIMDbApikey(); requestIMDbRating(title, year, type); } else { reject(errorTip().noData); } } else { reject(errorTip().noData); } } else { if (consoleLog) console.log("Netflix IMDb Rating Error:\n" + error); reject(errorTip().error); } }); }); } function updateIMDbApikey() { if (IMDbApikey) IMDbApikeys.splice(IMDbApikeys.indexOf(IMDbApikey), 1); const index = Math.floor(Math.random() * IMDbApikeys.length); IMDbApikey = IMDbApikeys[index]; $tool.write(IMDbApikey, imdbApikeyCacheKey); } function get_IMDb_message(data) { let rating_message = "IMDb: โญ๏ธ N/A"; let tomatoes_message = ""; let country_message = ""; let ratings = data.Ratings; let awards_message = ""; if (data.Awards && data.Awards != "N/A") { awards_message = "๐Ÿ† " + data.Awards; } if (ratings.length > 0) { const imdb_source = ratings[0]["Source"]; if (imdb_source == "Internet Movie Database") { const imdb_votes = data.imdbVotes; const imdb_rating = ratings[0]["Value"]; rating_message = "IMDb: โญ๏ธ " + imdb_rating + " " + imdb_votes; if (data.Type == "movie") { if (ratings.length > 1) { const source = ratings[1]["Source"]; if (source == "Rotten Tomatoes") { const tomatoes = ratings[1]["Value"]; tomatoes_message = "Tomatoes: ๐Ÿ… " + tomatoes; } } } } } country_message = get_country_message(data.Country); return { rating: rating_message, tomatoes: tomatoes_message, country: country_message, awards: awards_message } } function get_douban_rating_message(data) { const s = data.replace(/\n| |&#\d{2}/g, '') .match(/\[(\u7535\u5f71|\u7535\u89c6\u5267)\].+?subject-cast\">.+?<\/span>/g); const average = s ? s[0].split(/">(\d\.\d) { emoji_country += countryEmoji(item) + " " + item + ", "; }); return emoji_country.slice(0, -2); } function errorTip() { return { noData: "โญ๏ธ N/A", error: "โŒ N/A" } } function IMDbApikeys() { const apikeys = [ "f75e0253", "d8bb2d6b", "ae64ce8d", "7218d678", "b2650e38", "8c4a29ab", "9bd135c2", "953dbabe", "1a66ef12", "3e7ea721", "457fc4ff", "d2131426", "9cc1a9b7", "e53c2c11", "f6dfce0e", "b9db622f", "e6bde2b9", "d324dbab", "d7904fa3", "aeaf88b9", "4e89234e",]; return apikeys; } function countryEmoji(name) { const emojiMap = { "Chequered": "๐Ÿ", "Triangular": "๐Ÿšฉ", "Crossed": "๐ŸŽŒ", "Black": "๐Ÿด", "White": "๐Ÿณ", "Rainbow": "๐Ÿณ๏ธโ€๐ŸŒˆ", "Pirate": "๐Ÿดโ€โ˜ ๏ธ", "Ascension Island": "๐Ÿ‡ฆ๐Ÿ‡จ", "Andorra": "๐Ÿ‡ฆ๐Ÿ‡ฉ", "United Arab Emirates": "๐Ÿ‡ฆ๐Ÿ‡ช", "Afghanistan": "๐Ÿ‡ฆ๐Ÿ‡ซ", "Antigua & Barbuda": "๐Ÿ‡ฆ๐Ÿ‡ฌ", "Anguilla": "๐Ÿ‡ฆ๐Ÿ‡ฎ", "Albania": "๐Ÿ‡ฆ๐Ÿ‡ฑ", "Armenia": "๐Ÿ‡ฆ๐Ÿ‡ฒ", "Angola": "๐Ÿ‡ฆ๐Ÿ‡ด", "Antarctica": "๐Ÿ‡ฆ๐Ÿ‡ถ", "Argentina": "๐Ÿ‡ฆ๐Ÿ‡ท", "American Samoa": "๐Ÿ‡ฆ๐Ÿ‡ธ", "Austria": "๐Ÿ‡ฆ๐Ÿ‡น", "Australia": "๐Ÿ‡ฆ๐Ÿ‡บ", "Aruba": "๐Ÿ‡ฆ๐Ÿ‡ผ", "ร…land Islands": "๐Ÿ‡ฆ๐Ÿ‡ฝ", "Azerbaijan": "๐Ÿ‡ฆ๐Ÿ‡ฟ", "Bosnia & Herzegovina": "๐Ÿ‡ง๐Ÿ‡ฆ", "Barbados": "๐Ÿ‡ง๐Ÿ‡ง", "Bangladesh": "๐Ÿ‡ง๐Ÿ‡ฉ", "Belgium": "๐Ÿ‡ง๐Ÿ‡ช", "Burkina Faso": "๐Ÿ‡ง๐Ÿ‡ซ", "Bulgaria": "๐Ÿ‡ง๐Ÿ‡ฌ", "Bahrain": "๐Ÿ‡ง๐Ÿ‡ญ", "Burundi": "๐Ÿ‡ง๐Ÿ‡ฎ", "Benin": "๐Ÿ‡ง๐Ÿ‡ฏ", "St. Barthรฉlemy": "๐Ÿ‡ง๐Ÿ‡ฑ", "Bermuda": "๐Ÿ‡ง๐Ÿ‡ฒ", "Brunei": "๐Ÿ‡ง๐Ÿ‡ณ", "Bolivia": "๐Ÿ‡ง๐Ÿ‡ด", "Caribbean Netherlands": "๐Ÿ‡ง๐Ÿ‡ถ", "Brazil": "๐Ÿ‡ง๐Ÿ‡ท", "Bahamas": "๐Ÿ‡ง๐Ÿ‡ธ", "Bhutan": "๐Ÿ‡ง๐Ÿ‡น", "Bouvet Island": "๐Ÿ‡ง๐Ÿ‡ป", "Botswana": "๐Ÿ‡ง๐Ÿ‡ผ", "Belarus": "๐Ÿ‡ง๐Ÿ‡พ", "Belize": "๐Ÿ‡ง๐Ÿ‡ฟ", "Canada": "๐Ÿ‡จ๐Ÿ‡ฆ", "Cocos (Keeling) Islands": "๐Ÿ‡จ๐Ÿ‡จ", "Congo - Kinshasa": "๐Ÿ‡จ๐Ÿ‡ฉ", "Congo": "๐Ÿ‡จ๐Ÿ‡ฉ", "Central African Republic": "๐Ÿ‡จ๐Ÿ‡ซ", "Congo - Brazzaville": "๐Ÿ‡จ๐Ÿ‡ฌ", "Switzerland": "๐Ÿ‡จ๐Ÿ‡ญ", "Cรดte dโ€™Ivoire": "๐Ÿ‡จ๐Ÿ‡ฎ", "Cook Islands": "๐Ÿ‡จ๐Ÿ‡ฐ", "Chile": "๐Ÿ‡จ๐Ÿ‡ฑ", "Cameroon": "๐Ÿ‡จ๐Ÿ‡ฒ", "China": "๐Ÿ‡จ๐Ÿ‡ณ", "Colombia": "๐Ÿ‡จ๐Ÿ‡ด", "Clipperton Island": "๐Ÿ‡จ๐Ÿ‡ต", "Costa Rica": "๐Ÿ‡จ๐Ÿ‡ท", "Cuba": "๐Ÿ‡จ๐Ÿ‡บ", "Cape Verde": "๐Ÿ‡จ๐Ÿ‡ป", "Curaรงao": "๐Ÿ‡จ๐Ÿ‡ผ", "Christmas Island": "๐Ÿ‡จ๐Ÿ‡ฝ", "Cyprus": "๐Ÿ‡จ๐Ÿ‡พ", "Czechia": "๐Ÿ‡จ๐Ÿ‡ฟ", "Czech Republic": "๐Ÿ‡จ๐Ÿ‡ฟ", "Germany": "๐Ÿ‡ฉ๐Ÿ‡ช", "Diego Garcia": "๐Ÿ‡ฉ๐Ÿ‡ฌ", "Djibouti": "๐Ÿ‡ฉ๐Ÿ‡ฏ", "Denmark": "๐Ÿ‡ฉ๐Ÿ‡ฐ", "Dominica": "๐Ÿ‡ฉ๐Ÿ‡ฒ", "Dominican Republic": "๐Ÿ‡ฉ๐Ÿ‡ด", "Algeria": "๐Ÿ‡ฉ๐Ÿ‡ฟ", "Ceuta & Melilla": "๐Ÿ‡ช๐Ÿ‡ฆ", "Ecuador": "๐Ÿ‡ช๐Ÿ‡จ", "Estonia": "๐Ÿ‡ช๐Ÿ‡ช", "Egypt": "๐Ÿ‡ช๐Ÿ‡ฌ", "Western Sahara": "๐Ÿ‡ช๐Ÿ‡ญ", "Eritrea": "๐Ÿ‡ช๐Ÿ‡ท", "Spain": "๐Ÿ‡ช๐Ÿ‡ธ", "Ethiopia": "๐Ÿ‡ช๐Ÿ‡น", "European Union": "๐Ÿ‡ช๐Ÿ‡บ", "Finland": "๐Ÿ‡ซ๐Ÿ‡ฎ", "Fiji": "๐Ÿ‡ซ๐Ÿ‡ฏ", "Falkland Islands": "๐Ÿ‡ซ๐Ÿ‡ฐ", "Micronesia": "๐Ÿ‡ซ๐Ÿ‡ฒ", "Faroe Islands": "๐Ÿ‡ซ๐Ÿ‡ด", "France": "๐Ÿ‡ซ๐Ÿ‡ท", "Gabon": "๐Ÿ‡ฌ๐Ÿ‡ฆ", "United Kingdom": "๐Ÿ‡ฌ๐Ÿ‡ง", "UK": "๐Ÿ‡ฌ๐Ÿ‡ง", "Grenada": "๐Ÿ‡ฌ๐Ÿ‡ฉ", "Georgia": "๐Ÿ‡ฌ๐Ÿ‡ช", "French Guiana": "๐Ÿ‡ฌ๐Ÿ‡ซ", "Guernsey": "๐Ÿ‡ฌ๐Ÿ‡ฌ", "Ghana": "๐Ÿ‡ฌ๐Ÿ‡ญ", "Gibraltar": "๐Ÿ‡ฌ๐Ÿ‡ฎ", "Greenland": "๐Ÿ‡ฌ๐Ÿ‡ฑ", "Gambia": "๐Ÿ‡ฌ๐Ÿ‡ฒ", "Guinea": "๐Ÿ‡ฌ๐Ÿ‡ณ", "Guadeloupe": "๐Ÿ‡ฌ๐Ÿ‡ต", "Equatorial Guinea": "๐Ÿ‡ฌ๐Ÿ‡ถ", "Greece": "๐Ÿ‡ฌ๐Ÿ‡ท", "South Georgia & South Sandwich Is lands": "๐Ÿ‡ฌ๐Ÿ‡ธ", "Guatemala": "๐Ÿ‡ฌ๐Ÿ‡น", "Guam": "๐Ÿ‡ฌ๐Ÿ‡บ", "Guinea-Bissau": "๐Ÿ‡ฌ๐Ÿ‡ผ", "Guyana": "๐Ÿ‡ฌ๐Ÿ‡พ", "Hong Kong SAR China": "๐Ÿ‡ญ๐Ÿ‡ฐ", "Hong Kong": "๐Ÿ‡ญ๐Ÿ‡ฐ", "Heard & McDonald Islands": "๐Ÿ‡ญ๐Ÿ‡ฒ", "Honduras": "๐Ÿ‡ญ๐Ÿ‡ณ", "Croatia": "๐Ÿ‡ญ๐Ÿ‡ท", "Haiti": "๐Ÿ‡ญ๐Ÿ‡น", "Hungary": "๐Ÿ‡ญ๐Ÿ‡บ", "Canary Islands": "๐Ÿ‡ฎ๐Ÿ‡จ", "Indonesia": "๐Ÿ‡ฎ๐Ÿ‡ฉ", "Ireland": "๐Ÿ‡ฎ๐Ÿ‡ช", "Israel": "๐Ÿ‡ฎ๐Ÿ‡ฑ", "Isle of Man": "๐Ÿ‡ฎ๐Ÿ‡ฒ", "India": "๐Ÿ‡ฎ๐Ÿ‡ณ", "British Indian Ocean Territory": "๐Ÿ‡ฎ๐Ÿ‡ด", "Iraq": "๐Ÿ‡ฎ๐Ÿ‡ถ", "Iran": "๐Ÿ‡ฎ๐Ÿ‡ท", "Iceland": "๐Ÿ‡ฎ๐Ÿ‡ธ", "Italy": "๐Ÿ‡ฎ๐Ÿ‡น", "Jersey": "๐Ÿ‡ฏ๐Ÿ‡ช", "Jamaica": "๐Ÿ‡ฏ๐Ÿ‡ฒ", "Jordan": "๐Ÿ‡ฏ๐Ÿ‡ด", "Japan": "๐Ÿ‡ฏ๐Ÿ‡ต", "Kenya": "๐Ÿ‡ฐ๐Ÿ‡ช", "Kyrgyzstan": "๐Ÿ‡ฐ๐Ÿ‡ฌ", "Cambodia": "๐Ÿ‡ฐ๐Ÿ‡ญ", "Kiribati": "๐Ÿ‡ฐ๐Ÿ‡ฎ", "Comoros": "๐Ÿ‡ฐ๐Ÿ‡ฒ", "St. Kitts & Nevis": "๐Ÿ‡ฐ๐Ÿ‡ณ", "North Korea": "๐Ÿ‡ฐ๐Ÿ‡ต", "South Korea": "๐Ÿ‡ฐ๐Ÿ‡ท", "Kuwait": "๐Ÿ‡ฐ๐Ÿ‡ผ", "Cayman Islands": "๐Ÿ‡ฐ๐Ÿ‡พ", "Kazakhstan": "๐Ÿ‡ฐ๐Ÿ‡ฟ", "Laos": "๐Ÿ‡ฑ๐Ÿ‡ฆ", "Lebanon": "๐Ÿ‡ฑ๐Ÿ‡ง", "St. Lucia": "๐Ÿ‡ฑ๐Ÿ‡จ", "Liechtenstein": "๐Ÿ‡ฑ๐Ÿ‡ฎ", "Sri Lanka": "๐Ÿ‡ฑ๐Ÿ‡ฐ", "Liberia": "๐Ÿ‡ฑ๐Ÿ‡ท", "Lesotho": "๐Ÿ‡ฑ๐Ÿ‡ธ", "Lithuania": "๐Ÿ‡ฑ๐Ÿ‡น", "Luxembourg": "๐Ÿ‡ฑ๐Ÿ‡บ", "Latvia": "๐Ÿ‡ฑ๐Ÿ‡ป", "Libya": "๐Ÿ‡ฑ๐Ÿ‡พ", "Morocco": "๐Ÿ‡ฒ๐Ÿ‡ฆ", "Monaco": "๐Ÿ‡ฒ๐Ÿ‡จ", "Moldova": "๐Ÿ‡ฒ๐Ÿ‡ฉ", "Montenegro": "๐Ÿ‡ฒ๐Ÿ‡ช", "St. Martin": "๐Ÿ‡ฒ๐Ÿ‡ซ", "Madagascar": "๐Ÿ‡ฒ๐Ÿ‡ฌ", "Marshall Islands": "๐Ÿ‡ฒ๐Ÿ‡ญ", "North Macedonia": "๐Ÿ‡ฒ๐Ÿ‡ฐ", "Mali": "๐Ÿ‡ฒ๐Ÿ‡ฑ", "Myanmar (Burma)": "๐Ÿ‡ฒ๐Ÿ‡ฒ", "Mongolia": "๐Ÿ‡ฒ๐Ÿ‡ณ", "Macau Sar China": "๐Ÿ‡ฒ๐Ÿ‡ด", "Northern Mariana Islands": "๐Ÿ‡ฒ๐Ÿ‡ต", "Martinique": "๐Ÿ‡ฒ๐Ÿ‡ถ", "Mauritania": "๐Ÿ‡ฒ๐Ÿ‡ท", "Montserrat": "๐Ÿ‡ฒ๐Ÿ‡ธ", "Malta": "๐Ÿ‡ฒ๐Ÿ‡น", "Mauritius": "๐Ÿ‡ฒ๐Ÿ‡บ", "Maldives": "๐Ÿ‡ฒ๐Ÿ‡ป", "Malawi": "๐Ÿ‡ฒ๐Ÿ‡ผ", "Mexico": "๐Ÿ‡ฒ๐Ÿ‡ฝ", "Malaysia": "๐Ÿ‡ฒ๐Ÿ‡พ", "Mozambique": "๐Ÿ‡ฒ๐Ÿ‡ฟ", "Namibia": "๐Ÿ‡ณ๐Ÿ‡ฆ", "New Caledonia": "๐Ÿ‡ณ๐Ÿ‡จ", "Niger": "๐Ÿ‡ณ๐Ÿ‡ช", "Norfolk Island": "๐Ÿ‡ณ๐Ÿ‡ซ", "Nigeria": "๐Ÿ‡ณ๐Ÿ‡ฌ", "Nicaragua": "๐Ÿ‡ณ๐Ÿ‡ฎ", "Netherlands": "๐Ÿ‡ณ๐Ÿ‡ฑ", "Norway": "๐Ÿ‡ณ๐Ÿ‡ด", "Nepal": "๐Ÿ‡ณ๐Ÿ‡ต", "Nauru": "๐Ÿ‡ณ๐Ÿ‡ท", "Niue": "๐Ÿ‡ณ๐Ÿ‡บ", "New Zealand": "๐Ÿ‡ณ๐Ÿ‡ฟ", "Oman": "๐Ÿ‡ด๐Ÿ‡ฒ", "Panama": "๐Ÿ‡ต๐Ÿ‡ฆ", "Peru": "๐Ÿ‡ต๐Ÿ‡ช", "French Polynesia": "๐Ÿ‡ต๐Ÿ‡ซ", "Papua New Guinea": "๐Ÿ‡ต๐Ÿ‡ฌ", "Philippines": "๐Ÿ‡ต๐Ÿ‡ญ", "Pakistan": "๐Ÿ‡ต๐Ÿ‡ฐ", "Poland": "๐Ÿ‡ต๐Ÿ‡ฑ", "St. Pierre & Miquelon": "๐Ÿ‡ต๐Ÿ‡ฒ", "Pitcairn Islands": "๐Ÿ‡ต๐Ÿ‡ณ", "Puerto Rico": "๐Ÿ‡ต๐Ÿ‡ท", "Palestinian Territories": "๐Ÿ‡ต๐Ÿ‡ธ", "Portugal": "๐Ÿ‡ต๐Ÿ‡น", "Palau": "๐Ÿ‡ต๐Ÿ‡ผ", "Paraguay": "๐Ÿ‡ต๐Ÿ‡พ", "Qatar": "๐Ÿ‡ถ๐Ÿ‡ฆ", "Rรฉunion": "๐Ÿ‡ท๐Ÿ‡ช", "Romania": "๐Ÿ‡ท๐Ÿ‡ด", "Serbia": "๐Ÿ‡ท๐Ÿ‡ธ", "Russia": "๐Ÿ‡ท๐Ÿ‡บ", "Rwanda": "๐Ÿ‡ท๐Ÿ‡ผ", "Saudi Arabia": "๐Ÿ‡ธ๐Ÿ‡ฆ", "Solomon Islands": "๐Ÿ‡ธ๐Ÿ‡ง", "Seychelles": "๐Ÿ‡ธ๐Ÿ‡จ", "Sudan": "๐Ÿ‡ธ๐Ÿ‡ฉ", "Sweden": "๐Ÿ‡ธ๐Ÿ‡ช", "Singapore": "๐Ÿ‡ธ๐Ÿ‡ฌ", "St. Helena": "๐Ÿ‡ธ๐Ÿ‡ญ", "Slovenia": "๐Ÿ‡ธ๐Ÿ‡ฎ", "Svalbard & Jan Mayen": "๐Ÿ‡ธ๐Ÿ‡ฏ", "Slovakia": "๐Ÿ‡ธ๐Ÿ‡ฐ", "Sierra Leone": "๐Ÿ‡ธ๐Ÿ‡ฑ", "San Marino": "๐Ÿ‡ธ๐Ÿ‡ฒ", "Senegal": "๐Ÿ‡ธ๐Ÿ‡ณ", "Somalia": "๐Ÿ‡ธ๐Ÿ‡ด", "Suriname": "๐Ÿ‡ธ๐Ÿ‡ท", "South Sudan": "๐Ÿ‡ธ๐Ÿ‡ธ", "Sรฃo Tomรฉ & Prรญncipe": "๐Ÿ‡ธ๐Ÿ‡น", "El Salvador": "๐Ÿ‡ธ๐Ÿ‡ป", "Sint Maarten": "๐Ÿ‡ธ๐Ÿ‡ฝ", "Syria": "๐Ÿ‡ธ๐Ÿ‡พ", "Swaziland": "๐Ÿ‡ธ๐Ÿ‡ฟ", "Tristan Da Cunha": "๐Ÿ‡น๐Ÿ‡ฆ", "Turks & Caicos Islands": "๐Ÿ‡น๐Ÿ‡จ", "Chad": "๐Ÿ‡น๐Ÿ‡ฉ", "French Southern Territories": "๐Ÿ‡น๐Ÿ‡ซ", "Togo": "๐Ÿ‡น๐Ÿ‡ฌ", "Thailand": "๐Ÿ‡น๐Ÿ‡ญ", "Tajikistan": "๐Ÿ‡น๐Ÿ‡ฏ", "Tokelau": "๐Ÿ‡น๐Ÿ‡ฐ", "Timor-Leste": "๐Ÿ‡น๐Ÿ‡ฑ", "Turkmenistan": "๐Ÿ‡น๐Ÿ‡ฒ", "Tunisia": "๐Ÿ‡น๐Ÿ‡ณ", "Tonga": "๐Ÿ‡น๐Ÿ‡ด", "Turkey": "๐Ÿ‡น๐Ÿ‡ท", "Trinidad & Tobago": "๐Ÿ‡น๐Ÿ‡น", "Tuvalu": "๐Ÿ‡น๐Ÿ‡ป", "Taiwan": "๐Ÿ‡จ๐Ÿ‡ณ", "Tanzania": "๐Ÿ‡น๐Ÿ‡ฟ", "Ukraine": "๐Ÿ‡บ๐Ÿ‡ฆ", "Uganda": "๐Ÿ‡บ๐Ÿ‡ฌ", "U.S. Outlying Islands": "๐Ÿ‡บ๐Ÿ‡ฒ", "United Nations": "๐Ÿ‡บ๐Ÿ‡ณ", "United States": "๐Ÿ‡บ๐Ÿ‡ธ", "USA": "๐Ÿ‡บ๐Ÿ‡ธ", "Uruguay": "๐Ÿ‡บ๐Ÿ‡พ", "Uzbekistan": "๐Ÿ‡บ๐Ÿ‡ฟ", "Vatican City": "๐Ÿ‡ป๐Ÿ‡ฆ", "St. Vincent & Grenadines": "๐Ÿ‡ป๐Ÿ‡จ", "Venezuela": "๐Ÿ‡ป๐Ÿ‡ช", "British Virgin Islands": "๐Ÿ‡ป๐Ÿ‡ฌ", "U.S. Virgin Islands": "๐Ÿ‡ป๐Ÿ‡ฎ", "Vietnam": "๐Ÿ‡ป๐Ÿ‡ณ", "Vanuatu": "๐Ÿ‡ป๐Ÿ‡บ", "Wallis & Futuna": "๐Ÿ‡ผ๐Ÿ‡ซ", "Samoa": "๐Ÿ‡ผ๐Ÿ‡ธ", "Kosovo": "๐Ÿ‡ฝ๐Ÿ‡ฐ", "Yemen": "๐Ÿ‡พ๐Ÿ‡ช", "Mayotte": "๐Ÿ‡พ๐Ÿ‡น", "South Africa": "๐Ÿ‡ฟ๐Ÿ‡ฆ", "Zambia": "๐Ÿ‡ฟ๐Ÿ‡ฒ", "Zimbabwe": "๐Ÿ‡ฟ๐Ÿ‡ผ", "England": "๐Ÿด๓ ง๓ ข๓ ฅ๓ ฎ๓ ง๓ ฟ", "Scotland": "๐Ÿด๓ ง๓ ข๓ ณ๓ ฃ๓ ด๓ ฟ", "Wales": "๐Ÿด๓ ง๓ ข๓ ท๓ ฌ๓ ณ๓ ฟ", } return emojiMap[name] ? emojiMap[name] : emojiMap["Chequered"]; } function Tool() { _node = (() => { if (typeof require == "function") { const request = require('request') return ({ request }) } else { return (null) } })() _isSurge = typeof $httpClient != "undefined" _isQuanX = typeof $task != "undefined" this.isSurge = _isSurge this.isQuanX = _isQuanX this.isResponse = typeof $response != "undefined" this.notify = (title, subtitle, message) => { if (_isQuanX) $notify(title, subtitle, message) if (_isSurge) $notification.post(title, subtitle, message) if (_node) console.log(JSON.stringify({ title, subtitle, message })); } this.write = (value, key) => { if (_isQuanX) return $prefs.setValueForKey(value, key) if (_isSurge) return $persistentStore.write(value, key) } this.read = (key) => { if (_isQuanX) return $prefs.valueForKey(key) if (_isSurge) return $persistentStore.read(key) } this.get = (options, callback) => { if (_isQuanX) { if (typeof options == "string") options = { url: options } options["method"] = "GET" $task.fetch(options).then(response => { callback(null, _status(response), response.body) }, reason => callback(reason.error, null, null)) } if (_isSurge) $httpClient.get(options, (error, response, body) => { callback(error, _status(response), body) }) if (_node) _node.request(options, (error, response, body) => { callback(error, _status(response), body) }) } this.post = (options, callback) => { if (_isQuanX) { if (typeof options == "string") options = { url: options } options["method"] = "POST" $task.fetch(options).then(response => { callback(null, _status(response), response.body) }, reason => callback(reason.error, null, null)) } if (_isSurge) $httpClient.post(options, (error, response, body) => { callback(error, _status(response), body) }) if (_node) _node.request.post(options, (error, response, body) => { callback(error, _status(response), body) }) } _status = (response) => { if (response) { if (response.status) { response["statusCode"] = response.status } else if (response.statusCode) { response["status"] = response.statusCode } } return response } }