// ==UserScript== // @name Wall Manager Sidekick (Farmville) // @namespace 160764 // @description Assists Wall Manager with Farmville posts // @include /(^http(s)?:\/\/(apps\.facebook\.com\/onthefarm\/|(.*)\.farmville\.com))/ // @include http*://www.facebook.com/plugins/serverfbml.php // @include https://www.facebook.com/pages/FB-Wall-Manager/* // @include /https?:\/\/www\.facebook\.com\/dialog\/apprequests\?(.*)(app_id=102452128776)(.*)/ // @include http*://www.facebook.com/lists/* // @exclude /(suggestionhub|neighbors)(\.php)?/ // @exclude http*farmville.com/flash.php?* // @license http://creativecommons.org/licenses/by-nc-nd/3.0/us/ // @version 12 // @copyright Charlie Ewing & Donald Mapes & Stephanie Mcilwain // @downloadURL https://update.greasyfork.icu/scripts/405/Wall%20Manager%20Sidekick%20%28Farmville%29.user.js // @updateURL https://update.greasyfork.icu/scripts/405/Wall%20Manager%20Sidekick%20%28Farmville%29.meta.js // ==/UserScript== (function() { var version = "12 for wm4"; var thisApp = "102452128776"; var defaultTO=null; function $(ID,root) {return (root||document).getElementById(ID);} //pass a single value to each child iframe //append that value to the location.hash of the located iframes function hashToIframes(v,doc) { doc=doc||document; var iframes = document.getElementsByTagName('iframe'); var f=0,iframe = iframes[f]; while (iframe){ var doc = iframe.contentWindow.document if (doc) { try{doc.location.hash+=v;}catch(e){} //hashToIframes(v,doc); } iframe=iframes[(f+=1)]; } } String.prototype.startsWith = function(s) {return (this.match("^"+s)==s)}; String.prototype.endsWith = function(s) {return (this.match(s+"$")==s)}; String.prototype.find = function(s) {return (this.indexOf(s) != -1);}; String.prototype.contains = function(s) {return (this.indexOf(s) != -1);}; String.prototype.noSpaces = function(s) {return (this.replace(/\s+/g,''));}; String.prototype.upperWords = function(s) {return (this+'').replace(/^(.)|\s(.)/g, function($1){return $1.toUpperCase();});}; Array.prototype.swap = function (x,y) {var b = this[x];this[x] = this[y];this[y] = b;return this;}; Array.prototype.pickRandom = function () {var i=Math.floor(Math.random()*this.length); return this[i];}; Array.prototype.inArray = function(value) {for(var i=this.length-1; i>=0; i--) {if(this[i]==value) return true;} return false;}; String.prototype.getUrlParam = function(s) { try{return this.split(s+"=")[1].split("&")[0];} catch(e){return "";} }; //sorts an array in such a way as to prevent //finding pea before peanut, or pea before english pea, and then effectively swapping their order //now also finds ash in cashew and places ash after cashew Array.prototype.fixOrder = function(){ var compareFunc = function(a,b){ var s1=a.toLowerCase(), s2=b.toLowerCase(); if (s1.contains(s2)) return -1; //when a contains b, a must come first else if (s2.contains(s1)) return 1 //when b contains a, b must come first else return 0; //no order change is required }; this.sort(compareFunc); return this; }; //reconstruct an array, turning it into definitions using a prefix Array.prototype.toDefinitions = function(prefix){ var mapFunc = function(o,i,p){ return prefix+o.noSpaces().toLowerCase(); }; return this.map(mapFunc); }; var suggestedVote=window.location.href.getUrlParam("suggestedVote"); if ((window.top==window.self) && (suggestedVote!=null)) { hashToIframes("&suggestedVote="+suggestedVote); }; //prevent reading data from top page because it does not contain useful information and can trick the sidekick if ((window.top==window.self) && !( window.location.href.match( /(^https:\/\/www\.facebook\.com\/pages\/FB-Wall-Manager\/)/ ) || window.location.href.match( /(^https:\/\/www\.facebook\.com\/lists\/)/ ) )) { //add listener which will hot potato details back to WM if in https top document if (location==top.location) try { //alert("top document"); if (location.href.startsWith("https:")) { //alert("https:"); var hotPotatoTicker; hotPotatoTicker=setInterval(function(){try{ var status=""; if ((status=location.hash.getUrlParam("status"))!="") { clearInterval(hotPotatoTicker); location.href="https://apps.facebook.com/?#status="+status; } }catch(e){ //alert("cannot pass details to alternate url"); }},1000); } } catch (e){ //alert("cannot interact with top document, assume this document is not the top document"); } return; } //returns the merge of any number of JSON objects //pass JSON objects as comma separated parameters //var newJSON = mergeJSON(a,b,c...n) //note: overwrites preexisting entries from earlier passed objects function mergeJSON () { var ret = {}; for (var a=0,l=arguments.length;a