Skip to content

Instantly share code, notes, and snippets.

@Rayer
Last active March 11, 2019 14:36
Show Gist options
  • Save Rayer/944f50058fd4ca7f5208991d6f5dd3bc to your computer and use it in GitHub Desktop.
Save Rayer/944f50058fd4ca7f5208991d6f5dd3bc to your computer and use it in GitHub Desktop.
NSArray* searchImageSuffix = @[@".jpg", @".jpeg", @".gif", @".tiff", @".png"];
if ([shortURL hasPrefix: @"sm"] && [shortURL length] <= 10 && isAllDigit([shortURL substringFromIndex: 2])) {
addShortenedURLMenuItem([@"NicoNico/" stringByAppendingString: shortURL],
[@"http://www.nicovideo.jp/watch/" stringByAppendingString: shortURL]);
} else if ([shortURL hasPrefix: @"id="] && [shortURL length] <= 12 && isAllDigit([shortURL substringFromIndex: 3])) {
addShortenedURLMenuItem([@"pixiv_illust/" stringByAppendingString: shortURL],
[@"http://www.pixiv.net/member_illust.php?mode=medium&illust_" stringByAppendingString: shortURL]);
} else if ([shortURL hasPrefix: @"mid="] && [shortURL length] <= 12 && isAllDigit([shortURL substringFromIndex: 4])) {
addShortenedURLMenuItem([@"pixiv_member/" stringByAppendingString: [shortURL substringFromIndex: 4]],
[@"http://www.pixiv.net/member.php?id=" stringByAppendingString: [shortURL substringFromIndex: 4]]);
} else if (^(NSArray* searchImageSuffix) {
for(NSString* suffix in searchImageSuffix) {
if([shortURL hasSuffix:suffix])
return TRUE;
}
return FALSE;
}(searchImageSuffix))
{
addShortenedURLMenuItem(@"Image search by GOOGLE", [@"https://www.google.com/searchbyimage?&image_url=" stringByAppendingString: shortURL]);
} else if ([shortURL length] == 4) {
addShortenedURLMenuItem([@"ppt.cc/" stringByAppendingString: shortURL],
[@"http://ppt.cc/" stringByAppendingString: shortURL]);
} else if ([shortURL length] == 5) {
addShortenedURLMenuItem([@"0rz.tw/" stringByAppendingString: shortURL],
[@"http://0rz.tw/" stringByAppendingString: shortURL]);
} else if ([shortURL length] == 6 || [shortURL length] == 7) {
addShortenedURLMenuItem([@"tinyurl.com/" stringByAppendingString: shortURL],
[@"http://tinyurl.com/" stringByAppendingString: shortURL]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment