// ==UserScript==
// @name            ImageFap Links
// @namespace       http://tampermonkey.net/
// @version         20200403
// @description     Make it easier to share images from imageFap
// @require         https://gist.githubusercontent.com/raw/2625891/waitForKeyElements.js
//                  The previous require is from a script of Brock Adams (Thanks to him!)
// @require         https://cdn.jsdelivr.net/npm/jszip/dist/jszip.min.js
// @author          nindogo
// @match           http*://*.imagefap.com/*
// @grant           GM_openInTab
// @downloadURL     https://github.com/nindogo/test_repo/raw/master/imageFap.user.js
// ==/UserScript==

waitForKeyElements('img[src^="https://cdn.imagefap.com/"', do_function);
waitForKeyElements('img[src^="https://images.imagefap.com/"', do_function);

function do_function(jNode) {
    var this_url = new URL(jNode[0].src)

    function open_in_tab(node) {
        var clickHandler = function(e) {
            GM_openInTab(node.href, 'loadInBackground');
            e.preventDefault();
        };
        node.addEventListener('click', clickHandler, false);
    }

    if (jNode[0].parentNode.href) {
        jNode[0].src = 'https://images.imagefap.com' + this_url.pathname;
        jNode[0].parentNode.target = '_blank';
        jNode[0].parentNode.href = 'https://images.imagefap.com' + this_url.pathname;
        new open_in_tab(jNode[0].parentNode)
        }
}

@@ -122,9 +122,9 @@
 0040
-3
+4
 %0A// 
@@ -437,16 +437,91 @@
 .min.js%0A
+// @require         https://cdn.jsdelivr.net/npm/jquery/dist/jquery.min.js%0A
 // @auth
@@ -618,16 +618,89 @@
 enInTab%0A
+// @grant           GM_xmlhttpRequest%0A// @run-at          document-start%0A
 // @down
@@ -796,16 +796,40 @@
 ript==%0A%0A
+// Image Gallary search%0A
 waitForK
@@ -974,84 +974,99 @@
 );%0A%0A
-function do_function(jNode) %7B%0A    var this_url = new URL(jNode%5B0%5D.src)%0A%0A    
+// Search page results%0AwaitForKeyElements('a.gal_title%5Bhref*=%22gallery.php%22%5D', set_title)%0A%0A%0A
 func
@@ -1086,28 +1086,24 @@
 tab(node) %7B%0A
-    
     var clic
@@ -1131,28 +1131,24 @@
 ) %7B%0A        
-    
 GM_openInTab
@@ -1188,20 +1188,16 @@
         
-    
 e.preven
@@ -1216,19 +1216,11 @@
     
- 
-   %7D;%0A    
+%7D;%0A
     
@@ -1272,21 +1272,90 @@
 false);%0A
-    %7D
+%7D%0A%0A%0Afunction do_function(jNode) %7B%0A    var this_url = new URL(jNode%5B0%5D.src)
 %0A%0A    if
@@ -1599,20 +1599,16 @@
         
-new 
 open_in_
@@ -1631,16 +1631,319 @@
 entNode)
+;%0A    %7D%0A%7D%0A%0Afunction set_title(jNode) %7B%0A    jNode%5B0%5D.target = '_blank';%0A    open_in_tab(jNode%5B0%5D);%0A%0A    GM_xmlhttpRequest(%7B%0A        method: 'GET',%0A        url: jNode%5B0%5D.href,%0A        context: jNode,%0A        onload: function(response)%7B%0A            response.context%5B0%5D.href = response.finalUrl + '?view=2';
 %0A       
@@ -1941,14 +1941,21 @@
 ;%0A        %7D%0A
+    %7D)%0A
 %7D%0A

Update imageFap.user.js