raingart / Nova-YouTube-extension

Apache License 2.0
199 stars 9 forks source link

[Feature] Not Interested + Don't recommend channel, Copy short URL & Watched Remover #158

Closed misspent closed 4 months ago

misspent commented 4 months ago

1st: I'd like to see something similar/clone of this. It's one of those QoL features that you'd wish was a feature YouTube made themselves.


2nd: Something that grabs the short URL from the video (right-click video > Copy video URL) and puts it on your clipboard for easier use. This is more of a dumb one, if I'm honest.

📋 Copy short URL to Clipboard with Notification
```js // ==UserScript== // @name Copy short URL to Clipboard with Notification // @version 1.0 // @description Convert YouTube URL format to the shortened version and copy to clipboard with notification. Keybind: Shift + c // @author Misspent & OpenAI // @namespace https://chatbot.theb.ai // @match *://www.youtube.com/* // @grant none // ==/UserScript== (function() { 'use strict'; function copyToClipboard(text) { return new Promise((resolve, reject) => { navigator.clipboard.writeText(text).then(function() { resolve(); }, function(err) { reject(err); }); }); } function showNotification(message) { var notification = document.createElement('div'); notification.style.position = 'fixed'; notification.style.top = '75px'; notification.style.right = '20px'; notification.style.padding = '10px'; notification.style.backgroundColor = '#023020'; notification.style.color = '#fff'; notification.style.borderRadius = '0px'; notification.style.fontSize = '16px'; notification.style.zIndex = '9999'; notification.textContent = message; document.body.appendChild(notification); setTimeout(function() { notification.remove(); }, 3000); } document.addEventListener('keydown', function(e) { if (e.shiftKey && e.key === 'C') { var currentURL = window.location.href; if (currentURL.includes('youtube.com/watch?v=')) { var videoId = currentURL.split('v=')[1]; var ampersandPosition = videoId.indexOf('&'); if (ampersandPosition !== -1) { videoId = videoId.substring(0, ampersandPosition); } var newURL = 'https://youtu.be/' + videoId; copyToClipboard(newURL).then(function() { showNotification('Shortened URL copied to clipboard'); }).catch(function(err) { console.error('Failed to copy shortened URL: ', err); }); } } }); })(); ```

3rd: You ever get tired of seeing watched videos pop-up on the home page + related section when watching a video? Me too, so my pal AI carried, because I'm shite at JS, and I ended up making something I'm sure people would like. You can press the delete key to make the removed videos show again, so if you forgot to add them to a list or want to see everything, then it's just a click away.

🗑️ Watched Remover
```js // ==UserScript== // @name Watched Remover (Delete Key) // @version 3.0 // @description Removes watched videos, which have a variable determining whether they should be deleted by default, toggled with the delete key. // @author Misspent & OpenAI // @namespace https://chatbot.theb.ai // @icon https://i.imgur.com/1RYzIiT.png // @match https://www.youtube.com/* // @grant GM_addStyle // @run-at document-idle // ==/UserScript== // Removes videos you've watched before/started watching (function () { 'use strict'; let isToggled = true; // false = keybind needed. true = activate default let progressVideos; function removeProgressVideos() { progressVideos.forEach(video => { if (video.querySelector('#progress')) { video.style.display = 'none'; } }); } function restoreProgressVideos() { progressVideos.forEach(video => { video.style.display = 'block'; }); } const observer = new MutationObserver(mutations => { progressVideos = document.querySelectorAll('ytd-rich-item-renderer, ytd-compact-video-renderer, ytd-video-renderer, ytd-playlist-panel-video-renderer'); // Add both selectors if (isToggled) { removeProgressVideos(); } }); observer.observe(document.documentElement, { childList: true, subtree: true }); document.addEventListener('keydown', function (event) { if (event.key === 'Delete') { isToggled = !isToggled; if (isToggled) { progressVideos = document.querySelectorAll('ytd-rich-item-renderer, ytd-compact-video-renderer, ytd-video-renderer, ytd-playlist-panel-video-renderer'); removeProgressVideos(); } else { restoreProgressVideos(); } } }); })(); ```

I'm asking for a lot here. I do not mean to come across as an asshat in any way, but what you've made is an AIO I've always wanted, and the fact you're willing to hear people out and add what (possible) stupid stuff they think of is the icing on the cake. Whether you add these or not, I'll still use your script, but these are some of those that'd decrease my and possibly other people's plugin load. If you add them that's. Keep up the excellent work. Regardless of whether you tell me to stfu, I'll still use this. I thought I'd ask, because why not? It doesn't hurt anyone. Thanks for all the effort you've put into this and for keeping it up.

Edit: I've got another request I'd like to possibly bring up to you that I just thought of, but that feels like asking for too much.

raingart commented 4 months ago

No problem. I'll take a look and maybe add it. Just now busy with other plugins - Download video. I was able to integrate from third-party services. But it was not possible to download directly. It turns out that steaming is divided into separate audio and video. Just two weeks ago I could access audio, but now I get error 403 (access denied)

By the way, the code is written well. There are some controversial points, but in general, in the upper half of the garbage that is published in greasyfork, etc.

p.s. don’t hesitate to write, ask, I’m not so arrogant as to refuse. Moreover, you have already tried and made not just a prototype, but a ready-made solution. The only thing I'm not going to do is block ads. It's too complicated, and it's very easy to break everything.

misspent commented 4 months ago

I've got an adblocker that's powerful, so thankfully ads aren't an issue. I normally use JDownloader 2 for YouTube. It's rare I ever download videos, and I've seen many scripts come ago that attempt to make a YouTube downloader, as they're combating it in a similar way they do ad-blockers. I hope it all works out for you, these features are always useful to someone.

The other request I mentioned
This took a while for me to fine-tune and get it all to work, AI, looking at other scripts and possible methods of doing it. I could only do it thanks to jQuery. However, it still shows the menu and can occasionally click on pages; it isn't meant to, but as I'm a big clown, I could not for the life of me figure out how to stop it from doing it on pages I didn't want it to. I also tried making it not show the menu so it's seamless and smooth; I tried making it not scroll down the page when it's doing its thing (80% sure the menu causes this); and the list goes on. I'll more than likely return to attempting to fix the issues with this if you aren't interested; however, I cannot blame you whatsoever if you aren't, as this stuff is a headache.
Auto-Click "Not Interested" (Keywords)
```js // ==UserScript== // @name Auto-Click "Not Interested" (Keywords) // @version 1.0 // @description Clicks "Not Interested" on YouTube videos with specific titles // @author Misspent & OpenAI // @namespace https://chat.openai.com // @icon https://i.imgur.com/2lG9W7i.png // @match https://www.youtube.com/* // @exclude https://www.youtube.com/watch?* // @exclude https://www.youtube.com/feed/subscriptions // @exclude https://www.youtube.com/@* // @require https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js // @run-at document-end // @grant none // ==/UserScript== (function () { 'use strict'; // Array of keywords to search for in video titles const keywords = ['Hogwarts', 'Cyberpunk']; // Flag to track if a video is currently being processed let processing = false; // Check if the current page is a YouTube page if (/youtube\.com\//.test(location.href)) { // Set up an interval to periodically check for videos setInterval(function () { // Process one video at a time if not already processing if (!processing) { keywords.forEach(keyword => { // Use a more specific selector to find video titles let videos = $(`ytd-rich-grid-renderer:has(#thumbnail) ytd-rich-item-renderer:contains('${keyword}')`); // Iterate through the found videos videos.each(function () { let videoTitle = $(this).text(); // Check if the video title contains the keyword if (videoTitle.includes(keyword)) { processing = true; // Set processing flag to true // Check if the video has [is-dismissed=''] let dismissedAttr = $(this).closest('ytd-rich-item-renderer').find('[is-dismissed=""]'); if (dismissedAttr.length === 0) { // Mark the video and click the "Not interested" button let richItemRenderer = $(this).closest('ytd-rich-item-renderer'); richItemRenderer.addClass("fucked").find("button.style-scope.yt-icon-button").click(); // Set a timeout to reset the processing flag after a short delay setTimeout(function () { $("yt-formatted-string:contains('Not interested')").click(); processing = false; }, 20); } else { console.log("Video contains [is-dismissed=''], skipping click."); processing = false; // Set processing flag to false without clicking } } }); }); } }, 500); // Adjust the interval time as needed (in milliseconds) } })(); ```
raingart commented 4 months ago

here is the test ver.

I have so far added only one plugin you published Copy URL to clipboard

raingart commented 4 months ago

use「Ctrl+C」

misspent commented 4 months ago

The test version copies it to the clipboard, but it does not notify you when you've done it, even though you added the option to edit the position, colour, and font size in the settings. I'll be going to bed very soon, and I'll for sure test anything you want me to tomorrow, good night and best of luck.


Edit - Unrelated Bug: Show dislike count doesn't seem to work for me when enabled in your script, but the script version does. I've tried figuring out why, but I'm going to assume it's outdated or a user issue on my end.

raingart commented 4 months ago

There is a plugin similar to your Watched Remover script. But I haven't tested this plugin because I'm too lazy to enable youtube history.

Screenshot from 2024-02-16 19-38-58

about the problem with displaying the notification. It displays correctly for me you can search for words on the pageURL copied. The notification element itself is framed in red, and how to show it in green.

Screenshot from 2024-02-16 19-45-02

As for dislikes, they work for me. If they are not there, the script will not run. You can see dislikes here. Perhaps they have been received but something is preventing them from being displayed

Screenshot from 2024-02-16 20-01-39

raingart commented 4 months ago

I tried to rewrite your script Auto-Click "Not Interested" (Keywords) spent about an hour. I don't want to do this anymore. There is a contextual a single copy and need to open/close asynchronously.

As a result, in 10 minutes I wrote the Add "Not Interested" button on thumbnails plugin. Just a link in the thumbnail that allows you to select a menu item in one click. it is incompatible with the Add "Watch Later" button on thumbnails plugin. Because it is a copy of it.

here is the test version https://gist.github.com/raingart/d7b88f0c91ed20e62170c7cdb5c5a5b0

misspent commented 4 months ago

Sorry about not checking; I didn't think for one second the watched remover would be in that feature as a dropdown.

I just enabled the Hide watched in the Thumbnail filter and it didn't pickup all the newly loaded ones on the home page, nor did it pickup all of the ones in the related section when watching a video (I had the percent on 5 and it didn't pickup ones at 80–100). I'm not sure whether it's an inconsistency on my end or not. I've disabled other scripts, and the issues still persist, so I'll more than likely carry on using the remover I made, as I have the advantage of using the "Toggle" it has. It picks up everything (very rare it doesn't).

I just enabled the Add "Not Interested" button on thumbnails, and it doesn't seem to be showing any type of button for me whatsoever. I've disabled themes + scripts that I assume might conflict, but it still doesn't want to work. This button will be useful when I only want to use the mouse and don't want to click twice, so thank you for that. Settings I have (I hate the hover over thumbnail to play it feature so it's disabled)  image

I tried another browser and got the dislike count to show up. I'm going to have to look into why that's happening on the main browser later. As for the URL copied, that's still not showing any notification. That's not an issue though, as I know when I use the keybind, it's another strange thing on my end I assume. I don't have much luck.


Used to dislike having my history tracked, but I made a new YouTube account and decided to keep it enabled. I'll more than likely disable it at some point, but we'll see. I rather like the idea of something that removes watched videos so I never have to watch them again. YouTube seems to me to be a loophole that constantly throws the same stuff at you regardless of whether you've already watched it or not, so if I remove it with a script, I know for a fact that it only removes ones I've seen.

Thanks for all the replies + describing everything. Time to checkout the script you sent.


TL;DR:

Watched Remover doesn't pickup all newly loaded watched videos. Not interested button doesn't show up for me, and I've got the Add "Watch Later" button on thumbnails disabled. The dislike count worked on another browser. I've got the same settings for my filter on that browser too.

misspent commented 4 months ago

Adding: document.body.querySelectorAll('#thumbnail #overlays #progress[style*="width"]') worked. Thank you, champ. Gotta love it 😄