[Pkg-mozext-commits] [tabmixplus] 24/34: Timestamps hyperlinks in Youtube open in new tab when "force to open in new tab" links to other sites (or all sites) is on

David Prévot taffit at moszumanska.debian.org
Mon Mar 9 23:28:08 UTC 2015


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository tabmixplus.

commit a102b6b1869bb2b0765caa1e4f3d457d51f825eb
Author: onemen <tabmix.onemen at gmail.com>
Date:   Tue Mar 3 08:54:36 2015 +0200

    Timestamps hyperlinks in Youtube open in new tab when "force to open in new tab" links to other sites (or all sites) is on
---
 modules/ContentClick.jsm | 28 ++++++++++++++++++++++------
 1 file changed, 22 insertions(+), 6 deletions(-)

diff --git a/modules/ContentClick.jsm b/modules/ContentClick.jsm
index bc9c43e..2203cbf 100644
--- a/modules/ContentClick.jsm
+++ b/modules/ContentClick.jsm
@@ -284,8 +284,12 @@ var ContentClickInternal = {
         * Get current page url
         * if user click a link while the page is reloading node.ownerDocument.location can be null
         */
-        let node = this.wrappedNode || this.wrappedOnClickNode;
-        let curpage = node.ownerDocument.URL || this.currentURL;
+        let youtube = /www\.youtube\.com\/watch\?v\=/;
+        let curpage = this.currentURL;
+        if (!youtube.test(curpage)) {
+          let node = this.wrappedNode || this.wrappedOnClickNode;
+          curpage = node.ownerDocument.URL || this.currentURL;
+        }
         let nodeHref = this.hrefFromOnClick || this.href || self._window.XULBrowserWindow.overLink;
         return self.isLinkToExternalDomain(curpage, nodeHref);
       });
@@ -853,9 +857,19 @@ var ContentClickInternal = {
     if (!/^(http|about)/.test(hrefFromOnClick || href))
       return null;
 
-    var currentURL = this._data.currentURL.toLowerCase().split("#")[0];
-    if (hrefFromOnClick)
-      return currentURL != hrefFromOnClick.toLowerCase().split("#")[0];
+    let current = this._data.currentURL.toLowerCase();
+    let youtube = /www\.youtube\.com\/watch\?v\=/;
+    let isYoutube = function(href) youtube.test(current) && youtube.test(href);
+    let isSamePath = function(href, att) makeURI(current).path.split(att)[0] == makeURI(href).path.split(att)[0];
+    let isSame = function(href, att) current.split(att)[0] == href.split(att)[0];
+
+    if (hrefFromOnClick) {
+      hrefFromOnClick = hrefFromOnClick.toLowerCase();
+      if (isYoutube(hrefFromOnClick))
+        return !isSamePath(hrefFromOnClick, '&t=');
+      else
+        return !isSame(hrefFromOnClick, '#');
+    }
 
     if (href)
       href = href.toLowerCase();
@@ -865,9 +879,11 @@ var ContentClickInternal = {
         this.checkOnClick(true))
       // javascript links, do nothing!
       return null;
+    else if (isYoutube(href))
+      return !isSamePath(href, '&t=');
     else
       // when the links target is in the same page don't open new tab
-      return currentURL != href.split("#")[0];
+      return !isSame(href, '#');
 
     return null;
   },

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mozext/tabmixplus.git



More information about the Pkg-mozext-commits mailing list