Skip to content

Instantly share code, notes, and snippets.

@chapterjason
Last active June 27, 2019 19:25
Show Gist options
  • Save chapterjason/63d2273f3d02a4ad40fd789101f8991d to your computer and use it in GitHub Desktop.
Save chapterjason/63d2273f3d02a4ad40fd789101f8991d to your computer and use it in GitHub Desktop.

Revisions

  1. chapterjason revised this gist Jun 27, 2019. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Automatic channel tab switch
    // @namespace http://tampermonkey.net/
    // @version 0.4
    // @version 0.5
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    @@ -21,11 +21,11 @@
    console.info("Automatic tab switch loaded!");

    document.addEventListener('yt-navigate-start', function(event){
    executeURL(event.detail.url);
    execute(event.detail.url);
    return false;
    });

    function executeURL(url){
    function execute(url){
    const parts = url.split('/').filter(notEmptyFilter);
    if(parts.length === 2 && (parts[0] === 'user' || parts[0] === 'channel')){
    const target = location.href + '/videos';
    @@ -34,5 +34,5 @@
    }
    }

    executeURL(location.pathname);
    execute(location.pathname);
    })();
  2. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Automatic channel tab switch
    // @namespace http://tampermonkey.net/
    // @version 0.3
    // @version 0.4
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
  3. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -7,6 +7,7 @@
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    // @downloadURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    // @match https://www.youtube.com/*
    // @run-at document-end
    // @grant none
    // ==/UserScript==

  4. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Automatic channel tab switch
    // @namespace http://tampermonkey.net/
    // @version 0.2
    // @version 0.3
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
  5. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -5,6 +5,7 @@
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    // @downloadURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    // @match https://www.youtube.com/*
    // @grant none
    // ==/UserScript==
  6. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // ==UserScript==
    // @name Automatic channel tab switch
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @version 0.2
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
  7. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -4,6 +4,7 @@
    // @version 0.1
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling <[email protected]>
    // @updateURL https://gist.github.com/chapterjason/63d2273f3d02a4ad40fd789101f8991d/raw/auto-switch.js
    // @match https://www.youtube.com/*
    // @grant none
    // ==/UserScript==
  8. chapterjason revised this gist Jun 27, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling
    // @author Jason Schilling <[email protected]>
    // @match https://www.youtube.com/*
    // @grant none
    // ==/UserScript==
  9. chapterjason revised this gist Jun 27, 2019. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -28,7 +28,6 @@
    const target = location.href + '/videos';
    location.href = target
    location.replace(target);

    }
    }

  10. chapterjason created this gist Jun 27, 2019.
    36 changes: 36 additions & 0 deletions auto-switch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    // ==UserScript==
    // @name Automatic channel tab switch
    // @namespace http://tampermonkey.net/
    // @version 0.1
    // @description Switches automatically to the videos tab if a channel or user page is requested
    // @author Jason Schilling
    // @match https://www.youtube.com/*
    // @grant none
    // ==/UserScript==

    (function() {
    'use strict';

    function notEmptyFilter(item){
    return item.length;
    }

    console.info("Automatic tab switch loaded!");

    document.addEventListener('yt-navigate-start', function(event){
    executeURL(event.detail.url);
    return false;
    });

    function executeURL(url){
    const parts = url.split('/').filter(notEmptyFilter);
    if(parts.length === 2 && (parts[0] === 'user' || parts[0] === 'channel')){
    const target = location.href + '/videos';
    location.href = target
    location.replace(target);

    }
    }

    executeURL(location.pathname);
    })();