<commit_before>/**
 * libopener
 *
 * by <NAME> <http://hbang.ws>
 * GPL licensed <http://hbang.ws/s/gpl>
 */

#import "HBLOGlobal.h"
#import "HBLibOpener.h"
#import <SpringBoard/SpringBoard.h>

@interface HBLibOpener (Private)
-(void)_preferencesUpdated;
@end

BOOL isHookedValue = NO;

BOOL HBLOShouldOverrideOpenURL(NSURL *url) {
	if (isHookedValue) {
		isHookedValue = NO;
		return NO;
	}

	for (NSString *key in [HBLibOpener sharedInstance].enabledHandlers) {
		NSURL *newUrl = ((NSURL *(^)(NSURL *url))[[HBLibOpener sharedInstance].handlers objectForKey:key])(url);

		if (newUrl) {
			isHookedValue = YES;
			[(SpringBoard *)[%c(SpringBoard) sharedApplication] applicationOpenURL:newUrl publicURLsOnly:NO];
			return YES;
		}
	}

	return NO;
}

void HBLOLoadPrefs() {
	[[HBLibOpener sharedInstance] _preferencesUpdated];
}

%ctor {
	[HBLibOpener sharedInstance];

	if (IN_SPRINGBOARD) {
		CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)HBLOLoadPrefs, CFSTR("ws.hbang.libopener/ReloadPrefs"), NULL, 0);
	}
}
<commit_msg>fix my stupidness. closes #1<commit_after>/**
 * libopener
 *
 * by <NAME> <http://hbang.ws>
 * GPL licensed <http://hbang.ws/s/gpl>
 */

#import "HBLOGlobal.h"
#import "HBLibOpener.h"
#import <SpringBoard/SpringBoard.h>

@interface HBLibOpener (Private)
-(void)_preferencesUpdated;
@end

static BOOL isHookedValue = NO;

static BOOL HBLOShouldOverrideOpenURL(NSURL *url) {
	if (isHookedValue) {
		isHookedValue = NO;
		return NO;
	}

	for (NSString *key in [HBLibOpener sharedInstance].enabledHandlers) {
		NSURL *newUrl = ((NSURL *(^)(NSURL *url))[[HBLibOpener sharedInstance].handlers objectForKey:key])(url);

		if (newUrl) {
			isHookedValue = YES;
			[(SpringBoard *)[%c(SpringBoard) sharedApplication] applicationOpenURL:newUrl publicURLsOnly:NO];
			return YES;
		}
	}

	return NO;
}

static void HBLOLoadPrefs() {
	[[HBLibOpener sharedInstance] _preferencesUpdated];
}

%ctor {
	[HBLibOpener sharedInstance];

	if (IN_SPRINGBOARD) {
		CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, (CFNotificationCallback)HBLOLoadPrefs, CFSTR("ws.hbang.libopener/ReloadPrefs"), NULL, 0);
	}
}

{'fraction_non_alphanumeric': 0.13858695652173914, 'fraction_numerical': 0.001358695652173913, 'mean_word_length': 5.673716012084592, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2585139', 'n_tokens_mistral': 872, 'n_tokens_neox': 818, 'n_words': 153}