         // This works by making wkwebview's longpress gestures pass through our gestureRecognizer first.
         // We have to allow textselection gestures to pass through while stopping long press of links.
         gestureRecognizer.delegate = self
-        tab.webView!.addGestureRecognizer(gestureRecognizer)
+        webView.addGestureRecognizer(gestureRecognizer)
     }
 
     func gestureRecognizerWithDescriptionFragment(_ descriptionFragment: String) -> UIGestureRecognizer? {

        selectionGestureRecognizer = nil

        var linkURL: URL?
        if let urlString = data["link"] as? String {
            linkURL = URL(string: urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.URLAllowedCharacterSet())!)
        }

        var imageURL: URL?
        if let urlString = data["image"] as? String {
            imageURL = URL(string: urlString.addingPercentEncoding(withAllowedCharacters: CharacterSet.URLAllowedCharacterSet())!)
        }

        if linkURL != nil || imageURL != nil {


        self.tab = tab

        guard let path = Bundle.main.path(forResource: "ContextMenu", ofType: "js"),
                let source = try? NSString(contentsOfFile: path, encoding: String.Encoding.utf8.rawValue) as String,
                let webView = tab.webView else {
            return
        }

        let userScript = WKUserScript(source: source, injectionTime: WKUserScriptInjectionTime.atDocumentEnd, forMainFrameOnly: false)
        webView.configuration.userContentController.addUserScript(userScript)

        // Disable the native long-press gesture recognizer to prevent the native WKWebView context
        // menu from appearing.
