Skip to content

Instantly share code, notes, and snippets.

@ericbroska
Last active December 12, 2015 06:49
Show Gist options
  • Save ericbroska/4731661 to your computer and use it in GitHub Desktop.
Save ericbroska/4731661 to your computer and use it in GitHub Desktop.
«Easy hack» #2: fake geolocating for Tweetbot (OS X).

A simple way to specify fake longitude and/or latitude for your tweets in Tweetbot

  1. Download llocy.dylib from here or compile it yourself from sources (see the llocy.mm below).

  2. Move this llocy.dylib to any place on your disk. I've placed in ~/Library/Application Support/Tweetbot/llocy.dylib so I'm going to use this path in examples below.

  3. Close Tweetbot if you haven't done it yet.

  4. Open Terminal.app (/Application/Utilities/Terminal.app) and enter (or just copy-paste) this command (without $):

    $ DYLD_INSERT_LIBRARIES="~/Library/Application Support/Tweetbot/llocy.dylib" open -a Tweetbot --args 56.885752 -109.294739  
    

    There you must change the path for llocy.dylib to your own, then replace 56.885752 and -109.294739 to your own latitude and longitude respectively.

  5. Done! Try to compose a new tweet now (^^,)

@ericbroska

/*
* clang -dynamiclib -framework CoreLocation -framework Foundation -o llocy.dylib llocy.mm
* $ DYLD_INSERT_LIBRARIES=/path/to/llocy.dylib open -a Tweetbot --args {LATITUDE_HERE} {LONGITUDE_HERE}
*
* Distributed under WTFPL License — http://www.wtfpl.net/about/
*/
#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
#include <objc/runtime.h>
static CLLocationCoordinate2D _c00rdinate = {0};
static int _l0aded = 0;
@interface CLLocation (LLocy)
- (CLLocationCoordinate2D)__coordinate;
@end
@implementation CLLocation (LLocy)
+ (void)load
{
method_exchangeImplementations(class_getInstanceMethod(self, @selector(coordinate)),
class_getInstanceMethod(self, @selector(__coordinate)));
}
- (CLLocationCoordinate2D)__coordinate
{
if (0 == _l0aded) {
if ([[[[NSProcessInfo processInfo] arguments] objectAtIndex: 1] hasPrefix: @"-psn"]) {
/*
* Use the original `-coordinate` method.
*/
return [self __coordinate];
}
NSUInteger argc = [[[NSProcessInfo processInfo] arguments] count];
NSArray *args = [[NSProcessInfo processInfo] arguments];
if (argc > 1) {
_c00rdinate.latitude = [[args objectAtIndex: 1] doubleValue] ?: _c00rdinate.latitude;
}
if (argc > 2) {
_c00rdinate.longitude = [[args objectAtIndex: 2] doubleValue] ?: _c00rdinate.longitude;
}
++_l0aded;
}
return _c00rdinate;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment