-
-
[原创]友秘存图插件
-
发表于:
2015-1-4 20:44
6714
-
前段时间写的一个Tweak,用来保存友秘(http://www.wumii.com/)的即将销毁的图片.
功能如下:
1. 友秘默认查看图片只有2秒后销毁,使用该Tweak后,延长到20秒.
2. 图片销毁时,会弹出一个对话框,问是否保存该图片,选择保存,会保存到相册中.
#import "substrate.h"
#import <UIKit/UIKit.h>
#import <objc/runtime.h>
#import "UIAlertView+Blocks.h"
typedef void (*pfn_viewDidLoad)(id self,SEL _cmd);
static pfn_viewDidLoad Real_viewDidLoad = NULL;
void Mine_viewDidLoad(id self,SEL _cmd);
typedef void (*pfn_imageDestroying)(id self,SEL _cmd);
static pfn_viewDidLoad Real_imageDestroying = NULL;
void Mine_imageDestroying(id self,SEL _cmd);
#define NS_TITLE @"保存图片"
#define NS_MESSAGE @"图片即将销毁,是否立即保存?"
MSInitialize
{
MSHookMessageEx(objc_getClass("WMBrowseTransientImageViewController"), @selector(viewDidLoad), (IMP)Mine_viewDidLoad, (IMP*)&Real_viewDidLoad);
MSHookMessageEx(objc_getClass("WMBrowseTransientImageViewController"), @selector(imageDestroying), (IMP)Mine_imageDestroying, (IMP*)&Real_imageDestroying);
}
void Mine_viewDidLoad(id self,SEL _cmd)
{
Real_viewDidLoad(self,_cmd);
// delay detory time.
objc_msgSend(self, @selector(setRemainTimeInMs:),20);
return;
}
void Mine_imageDestroying(id self,SEL _cmd)
{
RIButtonItem* cancelItem = [RIButtonItem itemWithLabel:@"放弃" action:^{
Real_imageDestroying(self,_cmd);
}];
// save image
RIButtonItem* saveItem = [RIButtonItem itemWithLabel:@"保存" action:^{
id zoomView = objc_msgSend(self, @selector(imageZoomableView));
UIImageView* imageView = (UIImageView*)objc_msgSend(zoomView, @selector(imageView));
UIImageWriteToSavedPhotosAlbum(imageView.image, self, nil, nil);
Real_imageDestroying(self,_cmd);
}];
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:NS_TITLE
message:NS_MESSAGE
cancelButtonItem:cancelItem
otherButtonItems:saveItem, nil];
[alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES];
}
Author: coltor#qq.com
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)