// ==UserScript== // @name KoC Merlin Token Domain Selector FRANCAIS // @icon https://rycamelot1-a.akamaihd.net/fb/e2/src/img/feeds/merlin_magical_token.jpg // @namespace KoCDomSel // @description Ce script recupere vos jetons merlins tous les jours depuis les publis Facebook! // @include *kingdomsofcamelot.com/fb/e2/src/claimVictoryToken_src.php* // @include *kingdomsofcamelot.com/fb/e2/src/merlinShare_src.php* // @include *kingdomsofcamelot.com/fb/e2/src/acceptToken_src.php* // @include *kingdomsofcamelot.com/fb/e2/src/helpFriend_src.php* // @include *kingdomsofcamelot.com/fb/e2/src/questshare_src.php* // @include *.kingdomsofcamelot.com/*main_src.php* // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_listValues // @grant GM_log // @grant GM_xmlhttpRequest // @grant unsafeWindow // @version 0.22a // @license http://creativecommons.org/licenses/by-nc-sa/3.0/ // @downloadURL https://update.greasyfork.icu/scripts/8949/KoC%20Merlin%20Token%20Domain%20Selector%20FRANCAIS.user.js // @updateURL https://update.greasyfork.icu/scripts/8949/KoC%20Merlin%20Token%20Domain%20Selector%20FRANCAIS.meta.js // ==/UserScript== // // March 2015 Barbarossa69 (www.facebook.com/barbarossa69) // Aided in development by Audrius Audriulaitis // Script adapted from "Auto Accept Kingdoms of Camelot Gifts" by Thomas Chapin // https://koc-battle-console.googlecode.com/svn/trunk/KoCDomainSelector.user.js // var Version = '0.22a'; String.prototype.trim = function () { return this.replace(/^\s+|\s+$/g, ''); } String.prototype.StripQuotes = function () { return this.replace(/"/g, ''); }; if (!this.JSON2) { JSON2 = {}; } (function () { function f(n) { return n < 10 ? '0' + n : n; } if (typeof Date.prototype.toJSON !== 'function') { Date.prototype.toJSON = function (key) { return this.getUTCFullYear() + '-' + f(this.getUTCMonth() + 1) + '-' + f(this.getUTCDate()) + 'T' + f(this.getUTCHours()) + ':' + f(this.getUTCMinutes()) + ':' + f(this.getUTCSeconds()) + 'Z'; }; String.prototype.toJSON = Number.prototype.toJSON = Boolean.prototype.toJSON = function (key) { return this.valueOf(); }; } var cx = /[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, escapable = /[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g, gap, indent, meta = { '\b' : '\\b', '\t' : '\\t', '\n' : '\\n', '\f' : '\\f', '\r' : '\\r', '"' : '\\"', '\\' : '\\\\' }, rep; function quote(string) { escapable.lastIndex = 0; return escapable.test(string) ? '"' + string.replace(escapable, function (a) { var c = meta[a]; return typeof c === 'string' ? c : '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }) + '"' : '"' + string + '"'; } function str(key, holder) { var i, k, v, length, mind = gap, partial, value = holder[key]; if (value && typeof value === 'object' && typeof value.toJSON === 'function') { value = value.toJSON(key); } if (typeof rep === 'function') { value = rep.call(holder, key, value); } switch (typeof value) { case 'string': return quote(value); case 'number': return isFinite(value) ? String(value) : 'null'; case 'boolean': case 'null': return String(value); case 'object': if (!value) { return 'null'; } gap += indent; partial = []; if (Object.prototype.toString.apply(value) === '[object Array]') { length = value.length; for (i = 0; i < length; i += 1) { partial[i] = str(i, value) || 'null'; } v = partial.length === 0 ? '[]' : gap ? '[\n' + gap + partial.join(',\n' + gap) + '\n' + mind + ']' : '[' + partial.join(',') + ']'; gap = mind; return v; } if (rep && typeof rep === 'object') { length = rep.length; for (i = 0; i < length; i += 1) { k = rep[i]; if (typeof k === 'string') { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } else { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = str(k, value); if (v) { partial.push(quote(k) + (gap ? ': ' : ':') + v); } } } } v = partial.length === 0 ? '{}' : gap ? '{\n' + gap + partial.join(',\n' + gap) + '\n' + mind + '}' : '{' + partial.join(',') + '}'; gap = mind; return v; } } if (typeof JSON2.stringify !== 'function') { JSON2.stringify = function (value, replacer, space) { var i; gap = ''; indent = ''; if (typeof space === 'number') { for (i = 0; i < space; i += 1) { indent += ' '; } } else if (typeof space === 'string') { indent = space; } rep = replacer; if (replacer && typeof replacer !== 'function' && (typeof replacer !== 'object' || typeof replacer.length !== 'number')) { throw new Error('JSON.stringify'); } return str('', { '' : value }); }; } if (typeof JSON2.parse !== 'function') { JSON2.parse = function (text, reviver) { var j; function walk(holder, key) { var k, v, value = holder[key]; if (value && typeof value === 'object') { for (k in value) { if (Object.hasOwnProperty.call(value, k)) { v = walk(value, k); if (v !== undefined) { value[k] = v; } else { delete value[k]; } } } } return reviver.call(holder, key, value); } cx.lastIndex = 0; if (cx.test(text)) { text = text.replace(cx, function (a) { return '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4); }); } if (text) { if (/^[\],:{}\s]*$/.test(text.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g, '@').replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g, ']').replace(/(?:^|:|,)(?:\s*\[)+/g, ''))) { j = eval('(' + text + ')'); return typeof reviver === 'function' ? walk({ '' : j }, '') : j; } } throw new SyntaxError('JSON.parse'); }; } })(); if (!this.GM_log) { GM_log = function (m) { console.log(m); } GM_registerMenuCommand = function (text, f) {} } if (!this.unsafeWindow) { //~~~ need helper to return values? unsafeWindow = {}; } function AddScript(script) { var a = document.createElement('script'); a.innerHTML = script; document.getElementsByTagName('head')[0].appendChild(a); return; } function inspect(obj, maxLevels, level) { var str = '', type, msg; // Start Input Validations // Don't touch, we start iterating at level zero if (level == null) level = 0; // At least you want to show the first level if (maxLevels == null) maxLevels = 1; if (maxLevels < 1) return 'Error: Levels number must be > 0'; // We start with a non null object if (obj == null) return 'Error: Object NULL'; // End Input Validations // Each Iteration must be indented str += ''; return str; } var nHtml = { FindByXPath : function (obj, xpath, nodetype) { if (!nodetype) { nodetype = XPathResult.FIRST_ORDERED_NODE_TYPE; } try { var q = document.evaluate(xpath, obj, null, nodetype, null); } catch (e) { GM_log('bad xpath:' + xpath); } if (nodetype == XPathResult.FIRST_ORDERED_NODE_TYPE) { if (q && q.singleNodeValue) { return q.singleNodeValue; } } else { if (q) { return q; } } return null; }, ClickWin : function (win, obj, evtName) { var evt = win.document.createEvent("MouseEvents"); evt.initMouseEvent(evtName, true, true, win, 0, 0, 0, 0, 0, false, false, false, false, 0, null); return !obj.dispatchEvent(evt); }, Click : function (obj) { return this.ClickWin(window, obj, 'click'); }, ClickTimeout : function (obj, millisec) { window.setTimeout(function () { return nHtml.ClickWin(window, obj, 'click'); }, millisec + Math.floor(Math.random() * 500)); }, SetSelect : function (obj, v) { for (var o = 0; o < obj.options.length; o++) { if (v == obj.options[o].value) { obj.options[o].selected = true; return true; } } return false; } }; function ById(id) { return document.getElementById(id); } function ByName(name) { return document.getElementsByName(name); } function AddText(box1, txt) { var txtObj; box1.appendChild(txtObj = document.createTextNode(txt)); return txtObj; } function AddHtml(box1, txt) { var txtObj; var sp = document.createElement('span'); sp.innerHTML = txt; box1.appendChild(sp); return txtObj; } function getServerId() { // domain for tokens may be passed in URL as &token_s parameter... var myServerId = KOCAutoAcceptGifts.options.UserDomain; var squery = /[\?,\&]token_s=\d+/; var dquery = /\d+/; var Sresult = dquery.exec(squery.exec(document.location.search)); if (Sresult) myServerId = Sresult; return myServerId; } function getBadServerId() { var myServerId = KOCAutoAcceptGifts.options.UserDomain; var squery = /[\?,\&]s=\d+/; var dquery = /\d+/; var Sresult = dquery.exec(squery.exec(document.location.search)); if (Sresult) myServerId = Sresult; return myServerId; } function getFeedId() { var myServerId = 'n/a'; var squery = /[\?,\&]f=\d+/; var dquery = /\d+/; var Sresult = dquery.exec(squery.exec(document.location.search)); if (Sresult) myServerId = Sresult; return myServerId; } function getFeedUserId() { var myServerId = 'n/a'; var squery = /[\?,\&]in=\d+/; var dquery = /\d+/; var Sresult = dquery.exec(squery.exec(document.location.search)); if (Sresult) myServerId = Sresult; return myServerId; } function createButton(label) { var a = document.createElement('a'); a.className = 'button20'; a.innerHTML = '' + label + ''; return a; } function htmlSelector (valNameObj, curVal, tags){ var m = []; m.push (''); } m.push (''); return m.join (''); } function AddMainTabLink(text, eventListener, mouseListener) { var a = createButton (text); a.className='tab'; a.title='Avez vous collectes vos jetons merlin aujourdhui?'; var tabs=document.getElementById('main_engagement_tabs'); if(!tabs) { tabs=document.getElementById('topnav_msg'); if (tabs) tabs=tabs.parentNode; } if (tabs) { var e = tabs.parentNode; var gmTabs = null; for (var i=0; i\ X\ '; document.body.appendChild(this.div); this.div.innerHTML = m; document.getElementById(prefix+'_X').addEventListener ('click', e_XClose, false); this.dragger = new CWinDrag (document.getElementById(prefix+'_bar'), this.div, enableDrag); this.div.addEventListener ('mousedown', e_divClicked, false); WinManager.add(prefix, this); function e_divClicked (){ t.focusMe(); } function e_XClose (){ t.show(false); if (t.onClose != null) t.onClose(); } function focusMe (){ t.setLayer(5); for (k in unsafeWindow.cpopupWins){ if (k != t.prefix) unsafeWindow.cpopupWins[k].unfocusMe(); } } function unfocusMe (){ t.setLayer(-5); } function getLocation (){ return {x: parseInt(this.div.style.left), y: parseInt(this.div.style.top)}; } function getDimensions (){ return {x: parseInt(this.div.style.width), y: parseInt(this.div.style.height)}; } function setLocation (loc){ t.div.style.left = loc.x +'px'; t.div.style.top = loc.y +'px'; } function setDimensions (loc){ t.div.style.width = loc.x +'px'; t.div.style.height = loc.y +'px'; } function destroy (){ document.body.removeChild(t.div); WinManager.delete (t.prefix); } function centerMe (parent){ if (parent == null){ var coords = getClientCoords(document.body); } else var coords = getClientCoords(parent); var x = ((coords.width - parseInt(t.div.style.width)) / 2) + coords.x; var y = ((coords.height - parseInt(t.div.style.height)) / 2) + coords.y; if (x<0) x = 0; if (y<0) y = 0; t.div.style.left = x +'px'; t.div.style.top = y +'px'; } function setEnableDrag (tf){ t.dragger.setEnable(tf); } function setLayer(zi){ t.div.style.zIndex = ''+ (this.BASE_ZINDEX + zi); } function getLayer(){ return parseInt(t.div.style.zIndex) - this.BASE_ZINDEX; } function getTopDiv(){ return document.getElementById(this.prefix+'_top'); } function getMainDiv(){ return document.getElementById(this.prefix+'_main'); } function show(tf){ if (tf){ t.div.style.display = 'block'; t.focusMe (); } else { t.div.style.display = 'none'; } return tf; } function toggleHide(t){ if (t.div.style.display == 'block') { return t.show (false); } else { return t.show (true); } } } function CWinDrag (clickableElement, movingDiv, enabled) { var t=this; this.setEnable = setEnable; this.setBoundRect = setBoundRect; this.lastX = null; this.lastY = null; this.enabled = true; this.moving = false; this.theDiv = movingDiv; this.body = document.body; this.ce = clickableElement; this.moveHandler = new CeventMove(this).handler; this.outHandler = new CeventOut(this).handler; this.upHandler = new CeventUp(this).handler; this.downHandler = new CeventDown(this).handler; this.clickableRect = null; this.boundRect = null; this.bounds = null; this.enabled = false; if (enabled == null) enabled = true; this.setEnable (enabled); function setBoundRect (b){ // this rect (client coords) will not go outside of current body this.boundRect = boundRect; this.bounds = null; } function setEnable (enable){ if (enable == t.enabled) return; if (enable){ clickableElement.addEventListener('mousedown', t.downHandler, false); t.body.addEventListener('mouseup', t.upHandler, false); } else { clickableElement.removeEventListener('mousedown', t.downHandler, false); t.body.removeEventListener('mouseup', t.upHandler, false); } t.enabled = enable; } function CeventDown (that){ this.handler = handler; var t = that; function handler (me){ if (t.bounds == null){ t.clickableRect = getClientCoords(clickableElement); t.bodyRect = getClientCoords(document.body); if (t.boundRect == null) t.boundRect = t.clickableRect; t.bounds = {top:10-t.clickableRect.height, bot:t.bodyRect.height-25, left:40-t.clickableRect.width, right:t.bodyRect.width-25}; } if (me.button==0 && t.enabled){ t.body.addEventListener('mousemove', t.moveHandler, true); t.body.addEventListener('mouseout', t.outHandler, true); t.lastX = me.clientX; t.lastY = me.clientY; t.moving = true; } } } function CeventUp (that){ this.handler = handler; var t = that; function handler (me){ if (me.button==0 && t.moving) _doneMoving(t); } } function _doneMoving (t){ t.body.removeEventListener('mousemove', t.moveHandler, true); t.body.removeEventListener('mouseout', t.outHandler, true); t.moving = false; } function CeventOut (that){ this.handler = handler; var t = that; function handler (me){ if (me.button==0){ t.moveHandler (me); } } } function CeventMove (that){ this.handler = handler; var t = that; function handler (me){ if (t.enabled && !t.wentOut){ var newTop = parseInt(t.theDiv.style.top) + me.clientY - t.lastY; var newLeft = parseInt(t.theDiv.style.left) + me.clientX - t.lastX; if (newTop < t.bounds.top){ // if out-of-bounds... newTop = t.bounds.top; _doneMoving(t); } else if (newLeft < t.bounds.left){ newLeft = t.bounds.left; _doneMoving(t); } else if (newLeft > t.bounds.right){ newLeft = t.bounds.right; _doneMoving(t); } else if (newTop > t.bounds.bot){ newTop = t.bounds.bot; _doneMoving(t); } t.theDiv.style.top = newTop + 'px'; t.theDiv.style.left = newLeft + 'px'; t.lastX = me.clientX; t.lastY = me.clientY; } } } } function getClientCoords(e){ if (e==null) return {x:null, y:null, width:null, height:null}; var x=0, y=0; ret = {x:0, y:0, width:e.clientWidth, height:e.clientHeight}; while (e.offsetParent != null){ ret.x += e.offsetLeft; ret.y += e.offsetTop; e = e.offsetParent; } return ret; } function TokenStartup (){ if (unsafeWindow.TokenLoaded) return; var metc = getClientCoords(document.getElementById('main_engagement_tabs')); if (metc.width==null || metc.width==0){ setTimeout (TokenStartup, 1000); return; } // add main tab link AddMainTabLink('JETONS', TokenPopup); unsafeWindow.TokenLoaded = true; if (KOCAutoAcceptGifts.options.OpenState == true) { TokenPopup(); } } function CheckTokenDay() { var date = new Date(); var utc = date.getTime() + (date.getTimezoneOffset() * 60000); var offset = -8 + (getDST(date)/60); var today = new Date(utc + (3600000 * offset)); var dd = today.getDate(); var mm = today.getMonth()+1; //January is 0! var yyyy = today.getFullYear(); if(dd<10) {dd='0'+dd} if(mm<10) {mm='0'+mm} today = dd+'/'+mm+'/'+yyyy; if (today != KOCAutoAcceptGifts.options.TokenDate) { KOCAutoAcceptGifts.options.TokenDate = today; KOCAutoAcceptGifts.options.TokenCount = 0; KOCAutoAcceptGifts.options.TokenCollected = false; KOCAutoAcceptGifts.options.BuildCollected = false; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); } } function getDST(today) { var yr = today.getFullYear(); var dst_start = new Date(yr+"-03-14T02:00:00"); // 2nd Sunday in March can't occur after the 14th var dst_end = new Date(yr+"-11-07T02:00:00"); // 1st Sunday in November can't occur after the 7th var day = dst_start.getDay(); // day of week of 14th dst_start.setDate(14-day); // Calculate 2nd Sunday in March of this year day = dst_end.getDay(); // day of the week of 7th dst_end.setDate(7-day); // Calculate first Sunday in November of this year var dstadj = 0; if (today >= dst_start && today < dst_end) { //does today fall inside of DST period? dstadj = (3600); // 60 mins! } return dstadj; } function AddFriends() { unsafeWindow.FB.getLoginStatus(function(response) { if (response.status != 'connected') { return; } }); unsafeWindow.FB.login(function (o) { if (o.authResponse) { var p = { access_token : o.authResponse.accessToken, }; unsafeWindow.FB.api('/me/friends', p, function(result) { KOCAutoAcceptGifts.options.FriendList = {}; var markup = ''; var FriendList = {0:'(Tout le monde)'}; for (var l in FriendList) { var selected = ""; if (KOCAutoAcceptGifts.options.SelectedFriendId == l) selected = "selected"; markup += ''; } var lists = result.data; lists.sort(function(a, b){ return a.name > b.name}); for(var i in lists){ if (lists[i].id) { KOCAutoAcceptGifts.options.FriendList[lists[i].id] = lists[i].name; var selected = ""; if (KOCAutoAcceptGifts.options.SelectedFriendId == lists[i].id) selected = "selected"; markup += ''; } } KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); document.getElementById('selectfriend').innerHTML = markup; }); } },{ scope : "user_friends" }); } function TokenPopup (){ CheckTokenDay(); if (TokenPop) { KOCAutoAcceptGifts.options.OpenState = TokenPop.toggleHide(TokenPop); KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); } else { var styles = ""; var NumTokens = unsafeWindow.seed.items.i599; if (!unsafeWindow.btLoaded) { var styles = '.xtab {padding-right: 5px; border:none; background:none; white-space:nowrap;}\ .xtabHD {padding-right: 5px; border-bottom:1px solid #888888; background:none; white-space:nowrap;font-weight:bold;font-size:11px;color:#888888;margin-left:10px;margin-right:10px;margin-top:5px;margin-bottom:5px;vertical-align:text-top;align:left}\ .xtabBR {padding-right: 5px; border:none; background:none; white-space:normal;}\ .xtabBRTop {padding-right: 5px; border:none; background:none; white-space:normal; vertical-align:top;}\ .btButton:Hover {color:#FFFF80;}\ tr.btPopupTop td {background-color:#342819; border:1px solid #000000; height: 21px; padding:0px; color:#FFFFFF;}\ .btPopMain {background-color:#F7F3E6; border:1px solid #000000; -moz-box-shadow:inset 0px 0px 10px #6a6a6a; -moz-border-radius-bottomright: 20px; -moz-border-radius-bottomleft: 20px; border-bottom-right-radius: 20px; border-bottom-left-radius: 20px; font-size:11px; color:#000000}\ .btPopup {border:5px ridge #666; -moz-border-radius:25px; border-radius:25px; -moz-box-shadow: 1px 1px 5px #000000;}\ .divHide {display:none}\ .btInput {font-size:10px; }'; } var FriendList = {0:'(Tout le monde)'}; for (var l in KOCAutoAcceptGifts.options.FriendList) { FriendList[l] = KOCAutoAcceptGifts.options.FriendList[l]; } var n = ''; n += '
   Configurations
'; n += ''; n += ''; n += '
Domaine de reception des Jetons: Activer 
Lien des Domaines pour coffres: 
'; n += '
'; n += ''; n += ''; n += ''; n += ''; n += '
Collecte des Jetons
Chercher Coffres  Nbr de Posts  Votre Mur Rev
Recherche Amis '+htmlSelector(FriendList,KOCAutoAcceptGifts.options.SelectedFriendId,'id=selectfriend class=btInput style="width:150px;" title="Selection amis pour vos recherches"')+' - Fb Id: 
Lien: 
Nettoyer votre mur Sauver Jeton Sauver Construct
'; n += '
'; n += ''; n += '

 

 

<<  >>
'; n += '
Barbarrossa KoC Domain Selector '+Version+'
'+KOCAutoAcceptGifts.options.TokenCount+' Jetons collectes aujourdhui.
Vous possedez actuellement '+NumTokens+' jetons.
'; n += '
 
'; n += ''; TokenPop = new CPopup('tkTokenOptions', 0, 0, 400, 360, true, function () { KOCAutoAcceptGifts.options.OpenState = false; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }); TokenPop.getTopDiv().innerHTML = '
COLLECTEUR JETONS Traduit par LastTemplar/KnightCathar
'; TokenPop.getMainDiv().innerHTML = n; if (KOCAutoAcceptGifts.options.TokenCollected) { document.getElementById('tktokencollected').innerHTML = 'Collecte'; } if (KOCAutoAcceptGifts.options.BuildCollected) { document.getElementById('tkbuildcollected').innerHTML = 'Collecte'; } if (NumTokens < 1) { unsafeWindow.jQuery('#tktokenusebutton').addClass('divHide'); } document.getElementById('RefreshFriendList').addEventListener ('click',function(){AddFriends()},false); document.getElementById('selectfriend').addEventListener ('change', function(){ KOCAutoAcceptGifts.options.SelectedFriendId = document.getElementById('selectfriend').value; if (KOCAutoAcceptGifts.options.SelectedFriendId != 0) { KOCAutoAcceptGifts.options.SearchUser = KOCAutoAcceptGifts.options.SelectedFriendId; } else { KOCAutoAcceptGifts.options.SearchUser = ''; } document.getElementById('tksearchuser').value = KOCAutoAcceptGifts.options.SearchUser; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); },false); document.getElementById('tkdomain').addEventListener('keyup', function () { if (isNaN(document.getElementById('tkdomain').value)) { document.getElementById('tkdomain').value = ""; } KOCAutoAcceptGifts.options.UserDomain = document.getElementById('tkdomain').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkenable').addEventListener('change', function () { KOCAutoAcceptGifts.options.Enabled = document.getElementById('tkenable').checked; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkyourwall').addEventListener('change', function () { KOCAutoAcceptGifts.options.YourWall = document.getElementById('tkyourwall').checked; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkrev').addEventListener('change', function () { KOCAutoAcceptGifts.options.Reversed = document.getElementById('tkrev').checked; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkchestdomain').addEventListener('keyup', function () { if (isNaN(document.getElementById('tkchestdomain').value)) { document.getElementById('tkchestdomain').value = ""; } KOCAutoAcceptGifts.options.ChestDomain = document.getElementById('tkchestdomain').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkchestdomainlist').addEventListener('keyup', function () { KOCAutoAcceptGifts.options.ChestDomainList = document.getElementById('tkchestdomainlist').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tknext').addEventListener('click', function () { var DomArray = document.getElementById('tkchestdomainlist').value.split(","); for (var d=0; d < DomArray.length; d++) { var found = false; if (DomArray[d] == KOCAutoAcceptGifts.options.ChestDomain) { if (d < DomArray.length-1) KOCAutoAcceptGifts.options.ChestDomain = DomArray[d+1] else KOCAutoAcceptGifts.options.ChestDomain = DomArray[0]; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); found = true; break; } } if (!found) { KOCAutoAcceptGifts.options.ChestDomain = DomArray[0]; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); } document.getElementById('tkchestdomain').value = KOCAutoAcceptGifts.options.ChestDomain; }, false); document.getElementById('tkprior').addEventListener('click', function () { var DomArray = document.getElementById('tkchestdomainlist').value.split(","); for (var d=0; d < DomArray.length; d++) { var found = false; if (DomArray[d] == KOCAutoAcceptGifts.options.ChestDomain) { if (d > 0) KOCAutoAcceptGifts.options.ChestDomain = DomArray[d-1] else KOCAutoAcceptGifts.options.ChestDomain = DomArray[DomArray.length-1]; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); found = true; break; } } if (!found) { KOCAutoAcceptGifts.options.ChestDomain = DomArray[DomArray.length-1]; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); } document.getElementById('tkchestdomain').value = KOCAutoAcceptGifts.options.ChestDomain; }, false); document.getElementById('tkbuildbmk').addEventListener('click', function () { if (document.getElementById('tklink').value != "") { KOCAutoAcceptGifts.options.BuildLink = document.getElementById('tklink').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); document.getElementById('tkbuildlink').title = document.getElementById('tklink').value; document.getElementById('tkbuildcollected').innerHTML = 'Saved'; } else { document.getElementById('tkbuildcollected').innerHTML = 'Aucun Lien'; } }, false); document.getElementById('tktokenbmk').addEventListener('click', function () { if (document.getElementById('tklink').value != "") { KOCAutoAcceptGifts.options.TokenLink = document.getElementById('tklink').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); document.getElementById('tktokenlink').title = document.getElementById('tklink').value; document.getElementById('tktokencollected').innerHTML = 'Saved'; } else { document.getElementById('tktokencollected').innerHTML = 'Aucun Lien'; } }, false); document.getElementById('tktokenlink').addEventListener('click', function () { if (KOCAutoAcceptGifts.options.TokenLink != "") { var goto = KOCAutoAcceptGifts.options.TokenLink; setTimeout (function (){window.top.location = goto;}, 0); } }, false); document.getElementById('tkbuildlink').addEventListener('click', function () { if (KOCAutoAcceptGifts.options.BuildLink != "") { var goto = KOCAutoAcceptGifts.options.BuildLink; setTimeout (function (){window.top.location = goto;}, 0); } }, false); document.getElementById('tkchestlink').addEventListener('click', function () { if (document.getElementById('tklink').value != "") { var goto = document.getElementById('tklink').value; // replace domain in link if specified... if (document.getElementById('tkchestdomain').value != "") { repstring = "=s%3A"+document.getElementById('tkchestdomain').value; goto = goto.replace(/=s%3A\d\d\d/g,repstring); goto = goto.replace(/&s=\d\d\d/g,repstring); } // if selected domain in list, get next domain from list for next time... var DomArray = document.getElementById('tkchestdomainlist').value.split(","); for (var d=0; d < DomArray.length; d++) { if (DomArray[d] == KOCAutoAcceptGifts.options.ChestDomain) { if (d < DomArray.length-1) KOCAutoAcceptGifts.options.ChestDomain = DomArray[d+1] else KOCAutoAcceptGifts.options.ChestDomain = DomArray[0]; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); break; } } setTimeout (function (){window.top.location = goto;}, 0); } }, false); document.getElementById('tksearchnum').addEventListener('keyup', function () { if (isNaN(document.getElementById('tksearchnum').value)) { document.getElementById('tksearchnum').value = "0"; } KOCAutoAcceptGifts.options.SearchNum = document.getElementById('tksearchnum').value; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tksearchuser').addEventListener('keyup', function () { KOCAutoAcceptGifts.options.SearchUser = document.getElementById('tksearchuser').value.trim(); KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); }, false); document.getElementById('tkgrabchest').addEventListener('click', function () { var FBUser = ''; if (KOCAutoAcceptGifts.options.SearchUser != '') { FBUser = KOCAutoAcceptGifts.options.SearchUser.split("?")[0].trim(); if (FBUser.split("facebook.com/")[1]) { FBUser = FBUser.split("facebook.com/")[1].trim(); } } if (FBUser != '' && !KOCAutoAcceptGifts.options.YourWall) { document.getElementById('tkmessage').innerHTML = 'Recherche coffre par '+FBUser+'...'; } else { document.getElementById('tkmessage').innerHTML = 'Recherche des coffres...'; } document.getElementById('tklink').value = ''; unsafeWindow.FB.getLoginStatus(function(response) { if (response.status != 'connected') { return; } }); unsafeWindow.FB.login(function (o) { if (o.authResponse) { var p = { access_token : o.authResponse.accessToken }; if (KOCAutoAcceptGifts.options.YourWall) { ClaimChest.URL = '/me/posts'; } else { if (FBUser != '') { ClaimChest.URL = '/'+FBUser+'/posts'; } else { ClaimChest.URL = '/me/home'; } } ClaimChest.p = p; ClaimChest.access_token = o.authResponse.accessToken; ClaimChest.NumPosts = 0; GetWallSearch(); } },{ scope : "read_stream,user_likes" }); }, false); document.getElementById('tkcleanwall').addEventListener('click', function () { document.getElementById('tkmessage').innerHTML = 'Recherche les posts Kabam sur votre mur...'; document.getElementById('tklink').value = ''; unsafeWindow.FB.getLoginStatus(function(response) { if (response.status != 'connected') { return; } }); unsafeWindow.FB.login(function (o) { if (o.authResponse) { var p = { access_token : o.authResponse.accessToken }; CleanWall.p = p; CleanWall.access_token = o.authResponse.accessToken; CleanWall.NumPosts = 0; CleanWall.NumCleaned = 0; CleanWall.NumChecked = 0; GetWallDel(); } },{ scope : "read_stream,user_likes" }); }, false); document.getElementById('tktokenuse').addEventListener('click', function () { document.getElementById('tkmessage').innerHTML = 'Sending request...'; var params=unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams); params.ftflag=0; new unsafeWindow.Ajax.Request(unsafeWindow.g_ajaxpath+"ajax/magicalboxPreview.php"+unsafeWindow.g_ajaxsuffix,{ method:"post", parameters:params, onSuccess:function(message){ var rslt=eval("("+message.responseText+")"); if(rslt.ok){ var params=unsafeWindow.Object.clone(unsafeWindow.g_ajaxparams); new unsafeWindow.Ajax.Request(unsafeWindow.g_ajaxpath+"ajax/magicalboxPick.php"+unsafeWindow.g_ajaxsuffix,{ method:"post", parameters:params, onSuccess:function(transport){ var rslt=eval("("+transport.responseText+")"); if(rslt.ok){ var itemId=rslt.prize; if (unsafeWindow.seed.items["i"+itemId]) { unsafeWindow.seed.items["i"+itemId] = parseInt(unsafeWindow.seed.items["i"+itemId])+1; unsafeWindow.ksoItems[itemId].add(); } else { unsafeWindow.seed.items["i"+itemId] = 1; unsafeWindow.ksoItems[itemId].add(); } var NumTokens = parseInt(unsafeWindow.seed.items.i599); if (NumTokens > 0) { NumTokens = NumTokens - 1; unsafeWindow.seed.items.i599 = (NumTokens).toString(); unsafeWindow.ksoItems[599].subtract(); } document.getElementById('tkmessage').innerHTML = 'You won '+unsafeWindow.itemlist["i"+rslt.prize].name+'!'; document.getElementById('tknum').innerHTML = parseInt(unsafeWindow.seed.items.i599) // if (NumTokens < 1) { // unsafeWindow.jQuery('#tktokenusebutton').addClass('divHide'); // } } else { document.getElementById('tkmessage').innerHTML = ''+rslt.msg+''; } } }); } else { document.getElementById('tkmessage').innerHTML = ''+rslt.msg+''; } } }); }, false); KOCAutoAcceptGifts.options.OpenState = true; KOCAutoAcceptGifts.SetOptions(KOCAutoAcceptGifts.options); TokenPop.show(true); } } function GetWallSearch() { var params = { access_token : ClaimChest.access_token, "limit" : KOCAutoAcceptGifts.options.SearchNum, "filter" : "others" }; if (ClaimChest.until != 'null') params = { access_token : ClaimChest.access_token, "limit" : KOCAutoAcceptGifts.options.SearchNum-ClaimChest.NumPosts, "filter" : "others", "until":ClaimChest.until, "__paging_token": ClaimChest.__paging_token}; unsafeWindow.FB.api(ClaimChest.URL, params , function (result) { if (result.data) { if (result.paging) { ClaimChest.__paging_token = result.paging.next.split("__paging_token=")[1]; ClaimChest.until = result.paging.next.split("&__paging_token=")[0]; ClaimChest.until = ClaimChest.until.split("until=")[1]; } else { ClaimChest.until = 'null';ClaimChest.__paging_token='empty'; } ClaimChest.posts = result.data; ClaimChest.NumPosts += result.data.length; ClaimChest.CheckNext(); } else { document.getElementById('tkmessage').innerHTML = ''+(result.error?result.error.type+' ('+result.error.code+') '+result.error.message:'Error encountered :(')+''; } }); } var ClaimChest = { posts : [], p : null, __paging_token : 'null', access_token : 'null', until : "null", NumPosts : 0, URL : '', CheckNext : function () { var t = ClaimChest; if (t.posts.length == 0) { if (ClaimChest.until != 'empty' && ClaimChest.until != 'null' && ClaimChest.NumPosts < KOCAutoAcceptGifts.options.SearchNum){ document.getElementById('tkmessage').innerHTML = 'Searching... ('+t.NumPosts+' checked)'; GetWallSearch(); } else { document.getElementById('tkmessage').innerHTML = 'No available Treasure Chests ('+t.NumPosts+' checked)'; } return; } var post = t.posts.splice(0,1)[0]; if (post.link && post.link.indexOf("apps.facebook.com/kingdomsofcamelot/convert.php?pl=1&ty=3&si=118&wccc=fcf-feed-118&ln=31&da=2")>=0 && (KOCAutoAcceptGifts.options.YourWall || (post.link.indexOf('&in='+ unsafeWindow.tvuid+'&')<0))) { KOCAutoAcceptGifts.Log(JSON2.stringify(post)); var likes_found = false; if (post.likes && post.likes.data.length > 0) {likes_found = true;} if (!likes_found) { if (KOCAutoAcceptGifts.options.YourWall) { unsafeWindow.FB.api('/' + post.id, "DELETE", ClaimChest.p, function (result) { if (result && !result.error) { document.getElementById('tklink').value = post.link; document.getElementById('tkmessage').innerHTML = 'Found Treasure Chest! :)'; KOCAutoAcceptGifts.Log(JSON2.stringify(post)); } else { ClaimChest.CheckNext(); } }); } else { unsafeWindow.FB.api('/' + post.id + '/likes', "POST", ClaimChest.p, function (result) { if (result && !result.error) { document.getElementById('tklink').value = post.link; document.getElementById('tkmessage').innerHTML = 'Coffre trouver provenant de '+post.from.name+'! :)'; KOCAutoAcceptGifts.Log(JSON2.stringify(post)); } else { ClaimChest.CheckNext(); } }); } } else { ClaimChest.CheckNext(); } } else { ClaimChest.CheckNext(); } }, } function GetWallDel() { var params = { access_token : CleanWall.access_token, "limit" : KOCAutoAcceptGifts.options.SearchNum, "filter" : "others" }; if (CleanWall.until != 'null') params = { access_token : CleanWall.access_token, "limit" : KOCAutoAcceptGifts.options.SearchNum-CleanWall.NumPosts, "filter" : "others", "until":CleanWall.until, "__paging_token": CleanWall.__paging_token}; var URL = '/me/posts'; unsafeWindow.FB.api(URL, params , function (result) { if (result.data) { if (result.paging) { CleanWall.__paging_token = result.paging.next.split("__paging_token=")[1]; CleanWall.until = result.paging.next.split("&__paging_token=")[0]; CleanWall.until = CleanWall.until.split("until=")[1]; } else { CleanWall.until = 'null';CleanWall.__paging_token='empty'; } CleanWall.posts = result.data; CleanWall.NumPosts += result.data.length; CleanWall.CheckNext(); } else { document.getElementById('tkmessage').innerHTML = ''+(result.error?result.error.type+' ('+result.error.code+') '+result.error.message:'Error encountered :(')+''; } }); } var CleanWall = { posts : [], p : null, __paging_token : 'null', access_token : 'null', until : "null", NumCleaned : 0, NumChecked : 0, NumPosts : 0, CheckNext : function () { var date_now = new Date(); var t = CleanWall; if (t.posts.length == 0) { document.getElementById('tkmessage').innerHTML = ''+t.NumCleaned+'/'+t.NumChecked+' Kabam posts deleted. ('+t.NumPosts+' checked)'; if (CleanWall.until != 'empty' && CleanWall.until != 'null' && CleanWall.NumPosts < KOCAutoAcceptGifts.options.SearchNum){ GetWallDel(); } return; } var post = t.posts.splice(0,1)[0]; if (post.application && post.application.id=='130402594779') { // belt and braces - only delete kabam posts CleanWall.NumChecked++; var likes_found = false; if (post.likes && post.likes.data.length > 0) {likes_found = true;} var other_post = false; var post_date = new Date (post.created_time); var post_time_hh = (date_now - post_date)/1000/60/60; var l_post_link = 'n/a'; if (post.link) l_post_link = post.link; other_post = (l_post_link.indexOf("si=303&wccc=fcf-feed-303&ln=31&da=2")>0) // Collected Daily Rewards || (l_post_link.indexOf("si=201&wccc=fcf-feed-201&ln=31&da=2")>0) // Faire || (l_post_link.indexOf("si=85&wccc=fcf-feed-85&ln=31&da=2")>0) // daily merlin token share || (l_post_link.indexOf("si=95&wccc=fcf-feed-95&ln=31&da=2")>0)// building posts || (l_post_link.indexOf("si=107&wccc=fcf-feed-107&ln=31&da=2")>0)// research posts || (l_post_link.indexOf("si=84&wccc=fcf-feed-84&ln=31&da=2")>0)// Mysterious Bounty chest || (l_post_link == 'n/a'); // other KoC posts with no link (?) if (likes_found || other_post) { unsafeWindow.FB.api('/' + post.id, "DELETE", CleanWall.p, function (result) { if (result && !result.error) { CleanWall.NumCleaned++; } else { KOCAutoAcceptGifts.Log(JSON2.stringify(result.error)); } CleanWall.CheckNext(); }); } else { CleanWall.CheckNext(); } } else { CleanWall.CheckNext(); } }, } var KOCAutoAcceptGifts = { startListenTime : null, options : null, isChrome : navigator.userAgent.toLowerCase().indexOf('chrome') > -1, DoUnsafeWindow : function (func, execute_by_embed) { if (this.isChrome || execute_by_embed) { var scr = document.createElement('script'); scr.innerHTML = func; document.body.appendChild(scr); } else { eval("unsafeWindow." + func); } }, Log : function (str) { GM_log(str); }, GetValue : function (name, default_val) { return GM_getValue(name, default_val); }, SetValue : function (name, val) { if (val == null || val == undefined) { GM_deleteValue(name); } else { return GM_setValue(name, val); } }, ListValues : function () { return GM_listValues(); }, ClearOptions : function () { this.SetValue('Options', JSON.stringify({})); }, GetOptions : function () { var json = this.GetValue('Options'); var options = {}; if (json !=null) options = JSON2.parse(json); var defOptions = { UserDomain : 457, Enabled : true, ChestDomain : '457,415,454,453,452,451,450,448,348', BuildLink : '', TokenLink : '', TokenDate : 0, TokenCount : 0, TokenCollected : false, BuildCollected : false, ChestDomainList : '', OpenState : false, SearchNum : 30, YourWall : false, Reversed : true, SearchUser : '', FriendList : {}, SelectedFriendId : 0, }; for (var n in defOptions) { if (options[n] != undefined) { continue; } options[n] = defOptions[n]; } return options; }, SetOptions : function (v) { setTimeout(function () {KOCAutoAcceptGifts.SetValue('Options', JSON2.stringify(v));},0); // get around GM_SetValue unsafeWindow error }, FactoryReset : function () { var stored_values = this.ListValues(); for (var n = 0; n < stored_values.length; n++) { GM_deleteValue(stored_values[n], null); } this.SetOptions({}); }, pageLoaded : false, giftAccepted : false, Listen : function () { var t = this; this.options = this.GetOptions(); this.startListenTime = new Date(); var domTickTimer = null; var domTickUpto = 0; var domTick = function (e) { if (!t.giftAccepted) { // Find the gift claiming container div var claim_gift = ById('claimgift'); if (!claim_gift) claim_gift = ById('claimhelp'); if (claim_gift) { // Look for the select drop-down var domain_selector = ById('serverid'); // Look for the next button var next_button1 = nHtml.FindByXPath(claim_gift, ".//a[contains(@onclick,'checkServer')]"); var next_button2 = nHtml.FindByXPath(claim_gift, ".//a[@class='nextbtn']"); var next_button3 = nHtml.FindByXPath(claim_gift, ".//a[contains(@onclick,'claimhelpform')]"); var back_button = nHtml.FindByXPath(claim_gift, ".//a"); if (domain_selector && (next_button1 || next_button2)) { for (var i = 0; i < domain_selector.options.length; i++) { if (domain_selector.options[i].value == UserDomain) { domain_selector.selectedIndex = i; if (next_button1) { nHtml.Click(next_button1); } else { nHtml.Click(next_button2); } t.giftAccepted = true; t.Log("Jeton Merlins collecte :)"); CheckTokenDay(); if (document.URL.search(/merlinShare_src.php/i) != -1) { t.options.TokenCollected = true; } if (document.URL.search(/accepttoken_src.php/i) != -1) { t.options.BuildCollected = true; } t.options.TokenCount = t.options.TokenCount + 1; t.SetOptions(t.options); break; } } } else { if (next_button3) { nHtml.Click(next_button3); } else { if (next_button2 || back_button) { t.giftAccepted = true; t.Log("Le jeton Merlin a pas pu etre collecte :("); var a = document.createElement('div'); a.innerHTML = '

Jeton Merlin non collecte.
(KoC sera recharge dans 10 secondes)
'; var claim_help_bdy = nHtml.FindByXPath(claim_gift, ".//div[contains(@class,'helpbodycontent')]"); if (!claim_help_bdy) claim_help_bdy = nHtml.FindByXPath(claim_gift, ".//div[@class='claimhelpbdy']"); if (claim_help_bdy) { claim_help_bdy.appendChild(a); } else { claim_gift.appendChild(a); } var goto1 = window.location.protocol+'//apps.facebook.com/kingdomsofcamelot/?s='+UserDomain; if (document.URL.search(/page=friendFeed/i)>0) { if (claim_gift.textContent.indexOf("Someone else has claimed this bonus.")>-1|| claim_gift.textContent.indexOf("You have already claimed this")>-1 || claim_gift.textContent.indexOf("You can not click on your own feed")>-1 || claim_gift.textContent.indexOf("You have followed an invalid feed link")>-1 || claim_gift.textContent.indexOf("You cannot click on your own feed")>-1) goto1 += '&s_expired_mt='+getBadServerId(); // to communicate with BOT script that merlin token expired and BOT should try another link; else goto1 += '&s_bad_mt='+getBadServerId(); // to communicate with BOT script that from this domain merlin token not taken; } setTimeout (function (){window.top.location = goto1;}, 10000); } else { if (domain_selector == null && (typeof unsafeWindow.checkServer == 'function')) { t.giftAccepted = true; t.Log("Suspected Blank Decree page..."); var FeedID = getFeedId(); var goto_null = window.location.protocol+'//apps.facebook.com/kingdomsofcamelot/?s='+UserDomain; if (FeedID !='n/a'){ goto_null = 'https://apps.facebook.com/kingdomsofcamelot/?f='+FeedID+'&t=118&lang=en&f='+FeedID+'&t=118&in='+getFeedUserId()+'&si=118&s='+UserDomain; t.Log("Jetons Merlins collectes :)"); CheckTokenDay(); t.options.TokenCount = t.options.TokenCount + 1; t.SetOptions(t.options); window.top.location = goto_null; } else { var a = document.createElement('div'); a.innerHTML = '

ID Jeton non trouvee.

Le jeton merlin ne peut etre collecte.
(KoC sera recharge dans 10 secondes)
'; claim_gift.appendChild(a); goto_null += '&s_expired_mt='+getBadServerId(); // I don't know, let's assume expired token, not sure what these are really used for lol (?) setTimeout (function (){window.top.location = goto_null;}, 10000); } } } } } } } if (!domTickTimer) { // is this even used anymore? domTickTimer = window.setTimeout(function () { domTickTimer = null; domTick(); domTickUpto++; }, 1000); } }; domTick(); } }; // start by reading options... KOCAutoAcceptGifts.options = KOCAutoAcceptGifts.GetOptions(); var UserDomain = getServerId(); var TokenPop = null; var ChestImage = 'https://rycamelot1-a.akamaihd.net/fb/e2/src/img/feeds/treasurechest_icon.png'; var TokenImage = 'https://rycamelot1-a.akamaihd.net/fb/e2/src/img/feeds/merlin_magical_token.jpg'; var BuildImage = 'https://rycamelot1-a.akamaihd.net/fb/e2/src/img/feeds/new_city_outskirts.jpg'; if (document.URL.search(/main_src.php/i) == -1) { if (KOCAutoAcceptGifts.options.Enabled) { KOCAutoAcceptGifts.Listen(); } } else { TokenStartup(); }