V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
yivanus
V2EX  ›  微信

撸了一个转发朋友圈的东西。。。有感兴趣的朋友吗??

  •  
  •   yivanus · 2016-11-13 20:48:44 +08:00 · 6034 次点击
    这是一个创建于 2957 天前的主题,其中的信息可能已经有所发展或是发生改变。

    有时候吧。需要转发一点收到的信息到朋友圈去。特别是别人发来的图片先下载到本地再去通过朋友圈发出来。 感觉好麻烦。 文字也是一样的需要先复制再去打开朋友圈来粘贴。麻烦死了。

    目前实现的功能,在聊天界面选中要转发的文字或者图片(目前只能一个),然后长按会出现 菜单,选中朋友圈就可以转发到朋友圈,在编辑界面也可以正常的编辑文字或者给图片加上文字描述什么的。

    有人感兴趣的话我就发一下代码。

    29 条回复    2017-01-14 14:15:01 +08:00
    murmur
        1
    murmur  
       2016-11-13 20:51:16 +08:00
    这不就锤子的 1step 么
    fchypzero
        2
    fchypzero  
       2016-11-13 21:00:03 +08:00 via Android
    xposed 不就有转发模块了么
    yivanus
        3
    yivanus  
    OP
       2016-11-13 21:03:56 +08:00
    我说的是 ios 上的啊。所以 xposed 是给 android 用的啊
    yivanus
        4
    yivanus  
    OP
       2016-11-13 21:04:54 +08:00
    用苹果的人不会为了这个功能去买个锤子吧?
    akaayy
        5
    akaayy  
       2016-11-13 21:13:03 +08:00 via Android
    感兴趣 发
    Lonely
        6
    Lonely  
       2016-11-13 21:16:27 +08:00 via iPhone
    直接贴 github 地址呗
    yivanus
        7
    yivanus  
    OP
       2016-11-13 21:25:46 +08:00
    @protocol messageNodeViewDelegate <NSObject>
    - (MMUIViewController *) getViewController;
    @end

    @interface MMTextView : NSObject
    {}
    - (void)setText:(id)arg1;
    @end

    @interface MMGrowTextView : NSObject
    {
    MMTextView *_textView;
    }
    - (void)postTextChangeNotification;
    @end

    @interface WCNewCommitViewController:MMUIViewController
    {
    MMGrowTextView *_textView;
    }
    @property(nonatomic) _Bool bCommmitOnlyText;
    - (id)initWithImages:(id)arg1 contacts:(id)arg2;
    @end

    @interface CMessageWrap:NSObject
    {
    NSString *m_nsContent;
    unsigned int m_uiMessageType;
    }
    @property(nonatomic) unsigned int m_uiMessageType;
    @property(retain, nonatomic) NSString *m_nsContent;
    + (id)getMsgImg:(id)arg1;
    - (_Bool)IsImgMsg;
    - (_Bool)IsTextMsg;
    @end


    @interface BaseMessageNodeView : NSObject
    {
    CMessageWrap *m_oMessageWrap;
    id <messageNodeViewDelegate> m_delegate;
    }
    - (id)m_msgWrap;
    @end

    @interface MMImage : NSObject
    {}
    - (id)initWithImage:(id)arg1;
    - (void)commonInit;
    @end

    int sharetext = 0;
    NSString *sharemsg = @"";

    %hook ImageMessageNodeView
    %new(v@:@)
    - (void)sharetotimeline{
    UIImage *uimage = [%c(CMessageWrap) getMsgImg: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")];
    MMImage *mmimage = [[%c(MMImage) alloc] initWithImage:uimage];
    [mmimage commonInit];
    NSMutableArray* array = [[NSMutableArray alloc] initWithObjects:mmimage, nil];

    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:array contacts:nil];

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];

    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
    }
    %end

    %hook TextMessageNodeView
    %new(v@:@)
    - (void)sharetotimeline{
    %log;

    CMessageWrap *msgwrap = MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap");
    NSString *msgtext =[msgwrap m_nsContent];
    sharemsg = msgtext;
    sharetext = 1;

    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:nil contacts:nil];

    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [wcvc setBCommmitOnlyText:1];

    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];

    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
    }
    %end

    %hook WCNewCommitViewController
    - (void)viewDidAppear:(_Bool)arg1{
    if(sharetext){
    MMGrowTextView *grow = MSHookIvar<MMGrowTextView *>(self,"_textView");
    MMTextView *mmtext = MSHookIvar<MMTextView *>(grow,"_textView");
    [mmtext setText:sharemsg];
    [grow postTextChangeNotification];
    sharemsg = @"";
    sharetext = 0;
    }
    }
    %end

    %hook BaseMessageNodeView
    - (void)showOperationMenu:(id)arg1 NeedDelete:(_Bool)arg2 {
    NSLog(@"=======%s",object_getClassName(self));
    CMessageWrap *mw = [self m_msgWrap];
    if([mw IsTextMsg] || [mw IsImgMsg]]){
    NSMutableArray *menuarray = [[NSMutableArray alloc]initWithArray:arg1];
    UIMenuItem *menu_timeline = [[UIMenuItem alloc] initWithTitle:@"朋友圈" action:@selector(sharetotimeline)];
    [menuarray insertObject:menu_timeline atIndex:0];
    [menu_timeline release];
    %orig(menuarray,arg2);
    }else{
    %orig;
    }
    }
    %end


    github 上不去。只好贴这里了。(方便自己发而已)
    designer
        8
    designer  
       2016-11-13 22:06:30 +08:00 via iPhone
    谢谢
    coreki
        9
    coreki  
       2016-11-13 22:37:56 +08:00 via iPhone
    mark ios 使用的?怎么试用
    hewigovens
        10
    hewigovens  
       2016-11-14 07:08:58 +08:00 via iPhone
    嗯,不 hook 微信果然做不到
    yivanus
        11
    yivanus  
    OP
       2016-11-14 09:48:53 +08:00
    @coreki 用 theos 编译一下就可以用了。创建一个新工程,然后把里面的 Tweak.xm 用这个内容替换掉。
    yfmir
        12
    yfmir  
       2016-11-22 09:03:53 +08:00 via iPhone
    mark
    kensla
        13
    kensla  
       2017-01-10 17:01:01 +08:00
    能给份完整的代码研究下吗
    yivanus
        14
    yivanus  
    OP
       2017-01-10 17:47:15 +08:00
    @kensla 这个已经是完整的了。。
    kensla
        15
    kensla  
       2017-01-11 09:07:20 +08:00 via iPhone
    @yivanus 我运行起来是无效果的
    yivanus
        16
    yivanus  
    OP
       2017-01-11 11:50:05 +08:00
    @kensla 越狱手机安装,在聊天对话框里面 长按消息,弹出的菜单中有一个朋友圈。选择朋友圈。
    kensla
        17
    kensla  
       2017-01-11 14:12:07 +08:00
    > Making all for tweak TimeLineTweak …
    ==> Preprocessing Tweak.xm …
    ==> Compiling Tweak.xm (armv7)…
    Tweak.xm:1:38: error: cannot find interface declaration for
    'MMUIViewController', superclass of 'WCNewCommitViewController'; did you
    mean 'UIViewController'?
    @interface WCNewCommitViewController:MMUIViewController
    ^~~~~~~~~~~~~~~~~~
    UIViewController
    kensla
        18
    kensla  
       2017-01-11 14:12:55 +08:00
    直接替换 Tweak.xm 的内容 编译报错了
    kensla
        19
    kensla  
       2017-01-11 14:18:29 +08:00
    6.5.3 版本还能用吗
    yivanus
        20
    yivanus  
    OP
       2017-01-11 18:03:28 +08:00
    @kensla 你这前后茅盾啊。。前面说运行起来没有效果。。。后面又说编译错误。。这就很奇怪了。如果你前面没有编译过又是如何运行起来的?这些代码的编译 如果有问题一开始就会报错。。。
    yivanus
        21
    yivanus  
    OP
       2017-01-11 18:16:07 +08:00
    @interface MMUIViewController : UIViewController
    {
    UINavigationController *m_navigationController;
    }
    @end
    @interface CMessageWrap:NSObject
    {}
    @property(retain, nonatomic) NSString *m_nsContent;
    + (id)getMsgImg:(id)arg1;
    + (id)getMaskedVideoMsgImgThumb:(id)arg1;
    @end
    @protocol messageNodeViewDelegate <NSObject>
    - (MMUIViewController *)getViewController;
    @end
    @interface BaseMessageNodeView : NSObject
    {
    CMessageWrap *m_oMessageWrap;
    id <messageNodeViewDelegate> m_delegate;
    }
    @end
    @interface MMTextView : NSObject
    {}
    - (void)setText:(id)arg1;
    @end
    @interface MMGrowTextView : NSObject
    {
    MMTextView *_textView;
    }
    - (void)postTextChangeNotification;
    @end

    @interface WCNewCommitViewController:MMUIViewController
    {
    MMGrowTextView *_textView;
    }
    @property(nonatomic) _Bool bCommmitOnlyText;
    - (id)initWithImages:(id)arg1 contacts:(id)arg2;
    - (void)OnDone;
    @end

    @interface SightMomentEditViewController : MMUIViewController
    {
    NSString *_realMoviePath;
    NSString *_moviePath;
    UIImage *_thumbImage;
    UIImage *_realThumbImage;
    }
    @property(nonatomic) _Bool directClose;
    @property(nonatomic) _Bool fromDraft;
    @property(retain, nonatomic) NSString *moviePath;
    @property(retain, nonatomic) NSString *realMoviePath;
    @property(retain, nonatomic) UIImage *realThumbImage;
    @property(retain, nonatomic) UIImage *thumbImage;
    - (id)init;
    @end

    @interface ImageMessageNodeView : BaseMessageNodeView
    {}
    - (void)onForward:(id)arg1;
    @end

    @interface MMImage : NSObject
    {}
    - (id)initWithImage:(id)arg1;
    - (void)commonInit;
    @end


    @interface TextMessageNodeView : BaseMessageNodeView
    {}
    - (void)onForward:(id)arg1;
    @end

    @interface VideoMessageNodeView : BaseMessageNodeView
    {
    NSString *m_videoPath;
    }
    - (id)getCoverImage;
    - (id)getMessageImageView;
    - (id)thumbImage;
    - (void)onForward:(id)arg1;
    @end


    int sharetext = 0;
    NSString *sharemsg = @"";

    %hook ImageMessageNodeView
    - (void)onForward:(id)arg1{
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    UIImage *uimage = [%c(CMessageWrap) getMsgImg: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")];
    MMImage *mmimage = [[%c(MMImage) alloc] initWithImage:uimage];
    [mmimage commonInit];
    NSMutableArray* array = [[NSMutableArray alloc] initWithObjects:mmimage, nil];
    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:array contacts:nil];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
    }
    %end



    %hook TextMessageNodeView
    - (void)onForward:(id)arg1{
    %log;
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    CMessageWrap *msgwrap = MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap");
    NSString *msgtext =[msgwrap m_nsContent];
    sharemsg = msgtext;
    sharetext = 1;
    WCNewCommitViewController *wcvc = [[%c(WCNewCommitViewController) alloc] initWithImages:nil contacts:nil];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    [wcvc setBCommmitOnlyText:1];
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
    }
    %end

    %hook VideoMessageNodeView
    - (void)onForward:(id)arg1{
    %log;
    SightMomentEditViewController *wcvc = [[%c(SightMomentEditViewController) alloc] init];
    NSLog(@"============all oc init here");
    NSString *vpath=MSHookIvar<NSString *>(self,"m_videoPath");
    NSLog(@"====video path%@",vpath);
    [wcvc setMoviePath:vpath];
    [wcvc setRealMoviePath:vpath];
    [wcvc setThumbImage:[%c(CMessageWrap) getMaskedVideoMsgImgThumb: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")]];
    [wcvc setRealThumbImage: [%c(CMessageWrap) getMaskedVideoMsgImgThumb: MSHookIvar<CMessageWrap *>(self,"m_oMessageWrap")]];
    [wcvc setFromDraft:1];
    [wcvc setDirectClose:1];
    UINavigationController *navC = [[UINavigationController alloc] initWithRootViewController:wcvc];
    id <messageNodeViewDelegate> delegate = MSHookIvar<id>(self,"m_delegate");
    MMUIViewController *vc= [delegate getViewController];
    NSLog(@"===%@",vc);
    [vc presentViewController:navC animated:YES completion:nil];
    [wcvc release];
    [navC release];
    }
    %end


    %hook WCNewCommitViewController
    - (id)initWithImages:(id)arg1 contacts:(id)arg2{
    NSLog(@"==%@",arg1);
    %log;
    return %orig;
    }

    - (void)viewDidAppear:(_Bool)arg1{
    if(sharetext){
    MMGrowTextView *grow = MSHookIvar<MMGrowTextView *>(self,"_textView");
    MMTextView *mmtext = MSHookIvar<MMTextView *>(grow,"_textView");
    [mmtext setText:sharemsg];
    [grow postTextChangeNotification];
    sharemsg = @"";
    sharetext = 0;
    }
    }
    %end

    这个是以前的代码。。。。后面自己也不想玩了。可能还有 bug 吧。想玩的就调试下吧。
    kensla
        22
    kensla  
       2017-01-11 19:32:41 +08:00
    @yivanus 这代码编译不了的
    kensla
        23
    kensla  
       2017-01-11 19:56:13 +08:00
    https://git.oschina.net/604217454/timelinetweak.git 这个是代码,方便测试下么
    yivanus
        24
    yivanus  
    OP
       2017-01-11 23:37:01 +08:00
    2017-01-11 23:35:57.780 xcodebuild[8802:302869] [MT] DVTPlugInManager: Required plug-in compatibility UUID E0A62D1F-3C18-4D74-BFE5-A4167D643966 for HHEnumeration-Xcode.ideplugin (com.huaxi.HHEnumeration) not present
    > Making all for tweak timeline …
    ==> Preprocessing Tweak.xm …
    ==> Compiling Tweak.xm (armv7)…
    ==> Linking tweak timeline (armv7)…
    clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7
    ==> Preprocessing Tweak.xm …
    ==> Compiling Tweak.xm (arm64)…
    ==> Linking tweak timeline (arm64)…
    clang: warning: libstdc++ is deprecated; move to libc++ with a minimum deployment target of iOS 7
    ==> Merging tweak timeline …
    2017-01-11 23:36:22.202 xcodebuild[9043:303448] [MT] DVTPlugInManager: Required plug-in compatibility UUID E0A62D1F-3C18-4D74-BFE5-A4167D643966 for HHEnumeration-Xcode.ideplugin (com.huaxi.HHEnumeration) not present
    ==> Signing timeline …
    > Making stage for tweak timeline …
    dpkg-deb: warning: deprecated compression type 'lzma'; use xz instead
    dpkg-deb: warning: ignoring 1 warning about the control file(s)
    dpkg-deb: building package 'com.xfunforx.timeline' in './packages/com.xfunforx.timeline_0.0.1-66+debug_iphoneos-arm.deb'.
    yivanus
        25
    yivanus  
    OP
       2017-01-11 23:40:17 +08:00
    @kensla 用你的那段代码编译的
    kensla
        26
    kensla  
       2017-01-12 08:19:41 +08:00 via iPhone
    @yivanus 那个码云的代码可以编译,在 6.5.3 版本没有效果,是不是不能用了?
    yivanus
        27
    yivanus  
    OP
       2017-01-12 21:01:23 +08:00
    @kensla 你一会说不能编译,一会说能编译,到底能不能编译??
    kensla
        28
    kensla  
       2017-01-13 17:58:55 +08:00 via iPhone
    @yivanus 你最开始发的代码不能编译,后面发的我放到开源中国的码云上了,码云那个可以编译。但是装到越狱手机上没有效果
    yivanus
        29
    yivanus  
    OP
       2017-01-14 14:15:01 +08:00
    微信的新版本更新后,有类找不到了。

    Jan 14 14:14:09 maruko WeChat[1501] <Error>: [timeline] Tweak.xm:241 ERROR: logos: nil class ImageMessageNodeView
    Jan 14 14:14:09 maruko WeChat[1501] <Error>: [timeline] Tweak.xm:241 ERROR: logos: nil class TextMessageNodeView
    Jan 14 14:14:09 maruko WeChat[1501] <Error>: [timeline] Tweak.xm:241 ERROR: logos: nil class VideoMessageNodeView
    Jan 14 14:14:09 maruko WeChat[1501] <Error>: [timeline] Tweak.xm:241 ERROR: logos: nil class BaseMessageNodeView
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   5363 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 07:10 · PVG 15:10 · LAX 23:10 · JFK 02:10
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.