Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. astamicu renamed this gist Nov 22, 2022. 1 changed file with 0 additions and 0 deletions.
  2. astamicu renamed this gist Nov 22, 2022. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  3. astamicu revised this gist Nov 22, 2022. 1 changed file with 21 additions and 18 deletions.
    39 changes: 21 additions & 18 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,24 +1,27 @@
    UPDATED 3.12.2020
    UPDATED 22.11.2022

    The old version of youtube with "disable_polymer" is not working anymore, so the script also stopped working.
    It's been two years since the last update, so here's the updated working script as per the comments below.

    Thanks to [JanTheDeveloper](https://gist.github.com/JanTheDeveloper) we have a new working script. Big up!

    I just changed the `'//span[contains(text(),"Watch later")]',` to `'//span[contains(text(),"Remove from")]',` and it should work for any playlist, not just the watch later one. (thanks to [hudsonite](https://gist.github.com/hudsonite) for the tip)
    Thanks to [BryanHaley](https://gist.github.com/BryanHaley) for this.
    ```javascript
    setInterval(function () {
    document.querySelector('#primary button[aria-label="Action menu"]').click();
    var things = document.evaluate(
    '//span[contains(text(),"Remove from")]',
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null
    );
    for (var i = 0; i < things.snapshotLength; i++) {
    things.snapshotItem(i).click();
    }
    }, 1000);
    video = document.getElementsByTagName('ytd-playlist-video-renderer')[0];

    video.querySelector('#primary button[aria-label="Action menu"]').click();

    var things = document.evaluate(
    '//span[contains(text(),"Remove from")]',
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null
    );

    for (var i = 0; i < things.snapshotLength; i++)
    {
    things.snapshotItem(i).click();
    }
    }, 500);
    ```

    I moved the old working code to another [gist](https://gist.github.com/astamicu/e35e7088a8e1253863915ff1067fd6d0)
    Non-english users will need to change "Action menu" and "Remove from" to what YouTube uses for their localization.
  4. astamicu revised this gist Dec 3, 2020. 1 changed file with 21 additions and 37 deletions.
    58 changes: 21 additions & 37 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,40 +1,24 @@
    UPDATE 17.10.2019

    Only works on old youtube skin.

    //added "&disable_polymer=true" after playlist link

    Also, saw this now, there is a "remove watched" button.

    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL&disable_polymer=true) on youtube.
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
    var interval = setInterval(removeOne, 30) // execute removeOne() every 30 milliseconds

    var lastNumVideos = 0 // the number of displayed videos in the last execution of removeOne()

    function removeOne () {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length // number of videos displayed
    if (numVideos === lastNumVideos) {
    return // skip removal if the previously removed video is still present
    UPDATED 3.12.2020

    The old version of youtube with "disable_polymer" is not working anymore, so the script also stopped working.

    Thanks to [JanTheDeveloper](https://gist.github.com/JanTheDeveloper) we have a new working script. Big up!

    I just changed the `'//span[contains(text(),"Watch later")]',` to `'//span[contains(text(),"Remove from")]',` and it should work for any playlist, not just the watch later one. (thanks to [hudsonite](https://gist.github.com/hudsonite) for the tip)
    ```javascript
    setInterval(function () {
    document.querySelector('#primary button[aria-label="Action menu"]').click();
    var things = document.evaluate(
    '//span[contains(text(),"Remove from")]',
    document,
    null,
    XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,
    null
    );
    for (var i = 0; i < things.snapshotLength; i++) {
    things.snapshotItem(i).click();
    }
    if (numVideos < 1) {
    try {
    document.querySelector('.browse-items-load-more-button').click() // click load more if there are no displayed videos
    } catch (err) {
    console.log('Load More button is missing. Refresh the page and restart the script to remove more videos.')
    clearInterval(interval) // stop repeating removeOne()
    }
    } else {
    document.querySelector('.pl-video-edit-remove').click() // remove top most video
    lastNumVideos = numVideos
    }
    }
    }, 1000);
    ```
    4. Press the enter key
    5. Watch your watch later playlist empty in realtime :D

    If you need to stop the script simply close or refresh the playlist's tab in your browser.

    I haven't tried, but this should work on other playlists as well.
    I moved the old working code to another [gist](https://gist.github.com/astamicu/e35e7088a8e1253863915ff1067fd6d0)
  5. astamicu revised this gist Oct 17, 2019. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,9 @@
    UPDATE 17.10.2019

    Only works on old youtube skin.

    //added "&disable_polymer=true" after playlist link

    Also, saw this now, there is a "remove watched" button.

    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL&disable_polymer=true) on youtube.
  6. astamicu revised this gist Oct 17, 2019. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,5 @@
    UPDATE 17.10.2019

    Only works on old youtube skin.
    //added "&disable_polymer=true" after playlist link
    Also, saw this now, there is a "remove watched" button.
  7. astamicu revised this gist Oct 17, 2019. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,9 @@
    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL) on youtube.
    UPDATE 17.10.2019
    Only works on old youtube skin.
    //added "&disable_polymer=true" after playlist link
    Also, saw this now, there is a "remove watched" button.

    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL&disable_polymer=true) on youtube.
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
  8. Ash revised this gist Jul 3, 2017. 1 changed file with 7 additions and 7 deletions.
    14 changes: 7 additions & 7 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,24 +2,24 @@
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
    var interval = setInterval(removeOne, 30)
    var interval = setInterval(removeOne, 30) // execute removeOne() every 30 milliseconds

    var lastNumVideos = 0
    var lastNumVideos = 0 // the number of displayed videos in the last execution of removeOne()

    function removeOne () {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length // number of videos displayed
    if (numVideos === lastNumVideos) {
    return
    return // skip removal if the previously removed video is still present
    }
    if (numVideos < 1) {
    try {
    document.querySelector('.browse-items-load-more-button').click()
    document.querySelector('.browse-items-load-more-button').click() // click load more if there are no displayed videos
    } catch (err) {
    console.log('Load More button is missing. Refresh the page and restart the script to remove more videos.')
    clearInterval(interval)
    clearInterval(interval) // stop repeating removeOne()
    }
    } else {
    document.querySelector('.pl-video-edit-remove').click()
    document.querySelector('.pl-video-edit-remove').click() // remove top most video
    lastNumVideos = numVideos
    }
    }
  9. Ash revised this gist Jul 2, 2017. 1 changed file with 0 additions and 2 deletions.
    2 changes: 0 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,4 @@ function removeOne () {

    If you need to stop the script simply close or refresh the playlist's tab in your browser.

    Enjoy! :D

    I haven't tried, but this should work on other playlists as well.
  10. Ash revised this gist Jul 2, 2017. 1 changed file with 4 additions and 4 deletions.
    8 changes: 4 additions & 4 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -11,18 +11,18 @@ function removeOne () {
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 2) {
    if (numVideos < 1) {
    try {
    document.querySelector('.browse-items-load-more-button').click()
    } catch (err) {
    console.log('Load More button is missing. Refresh the page and restart the script to remove more videos.')
    clearInterval(interval)
    }
    } else {
    document.querySelector('.pl-video-edit-remove').click()
    lastNumVideos = numVideos
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNumVideos = numVideos
    }

    ```
    4. Press the enter key
    5. Watch your watch later playlist empty in realtime :D
  11. Ash revised this gist Jul 2, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
    var interval = setInterval(removeOne, 750)
    var interval = setInterval(removeOne, 30)

    var lastNumVideos = 0

    @@ -20,7 +20,7 @@ function removeOne () {
    }
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    lastNumVideos = numVideos
    }

    ```
  12. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -27,7 +27,7 @@ function removeOne () {
    4. Press the enter key
    5. Watch your watch later playlist empty in realtime :D

    If you need to stop the script simply close or refresh the playlists's tab in your browser.
    If you need to stop the script simply close or refresh the playlist's tab in your browser.

    Enjoy! :D

  13. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -31,6 +31,4 @@ If you need to stop the script simply close or refresh the playlists's tab in yo

    Enjoy! :D

    I haven't tried, but this should work on other playlists as well.

    The script can be left open forever without flooding youtube with requests, it will just make lots of unnecessary DOM queries, which shouldn't be a real problem.
    I haven't tried, but this should work on other playlists as well.
  14. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ function removeOne () {
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 1) {
    if (numVideos < 2) {
    try {
    document.querySelector('.browse-items-load-more-button').click()
    } catch (err) {
  15. Ash revised this gist Jul 2, 2017. 1 changed file with 18 additions and 11 deletions.
    29 changes: 18 additions & 11 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -2,20 +2,27 @@
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
    var lastNumVideos
    var interval = setInterval(removeOne, 750)

    function removeOne() {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    var lastNumVideos = 0

    function removeOne () {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 1) {
    try {
    document.querySelector('.browse-items-load-more-button').click()
    } catch (err) {
    console.log('Load More button is missing. Refresh the page and restart the script to remove more videos.')
    clearInterval(interval)
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
    setInterval(removeOne, 30)

    ```
    4. Press the enter key
    5. Watch your watch later playlist empty in realtime :D
  16. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -24,5 +24,6 @@ If you need to stop the script simply close or refresh the playlists's tab in yo

    Enjoy! :D

    I haven't tried, but this should work on other playlists as well.

    The script can be left open forever without flooding youtube with requests, it will just make lots of unnecessary DOM queries, which shouldn't be a real problem.
  17. Ash revised this gist Jul 2, 2017. 1 changed file with 9 additions and 9 deletions.
    18 changes: 9 additions & 9 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -5,15 +5,15 @@
    var lastNumVideos

    function removeOne() {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
    setInterval(removeOne, 30)
    ```
  18. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL) on youtube.
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome )
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome, Ctrl+Shift+K for firefox )
    3. paste this script into the console
    ``` javascript
    var lastNumVideos
  19. Ash revised this gist Jul 2, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -11,7 +11,7 @@ function removeOne() {
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    }
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
  20. Ash revised this gist Jul 2, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -8,10 +8,10 @@ function removeOne() {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    }
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
  21. Ash revised this gist Jul 2, 2017. No changes.
  22. Ash created this gist Jul 2, 2017.
    28 changes: 28 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,28 @@
    1. Open [your watch later playlist](https://www.youtube.com/playlist?list=WL) on youtube.
    2. Open the development console for your browser ( Ctrl+Shift+J for chrome )
    3. paste this script into the console
    ``` javascript
    var lastNumVideos

    function removeOne() {
    var numVideos = document.querySelectorAll('.pl-video-edit-remove').length
    if (numVideos === lastNumVideos) {
    return
    }
    if (numVideos < 10) {
    document.querySelector('.browse-items-load-more-button').click()
    }
    document.querySelector('.pl-video-edit-remove').click()
    lastNum = numVideos
    }
    setInterval(removeOne, 30)
    ```
    4. Press the enter key
    5. Watch your watch later playlist empty in realtime :D

    If you need to stop the script simply close or refresh the playlists's tab in your browser.

    Enjoy! :D


    The script can be left open forever without flooding youtube with requests, it will just make lots of unnecessary DOM queries, which shouldn't be a real problem.