Greasy Fork is available in English.

讨论 » 创建请求

Any script that could remove part of a URL link on a page?

§
发表于:2014-08-18
编辑于:2014-08-18

Any script that could remove part of a URL link on a page?

Youtube is really annoying me with their BS. Now for the videos in a Channel's Video Section, it adds a suffix to the video URL that turns that channel's entire library into a playlist, and automatically plays the next video.

For example, this is what my links look like when clicking on a video from the channel page:

youtube.com/watch?v=ffDfg2131Oo&list=UUsvazPPlhZlch0-Z3wPByeg&user=UCsvazPPlhZlch0-Z3wPByeg

And this is what they look like when after the next video has automatically been started:
youtube.com/watch?v=981B0c6utO8&list=UUsvazPPlhZlch0-Z3wPByeg&index=2&user=UCsvazPPlhZlch0-Z3wPByeg

The stuff that includes "&user=..." is a part of one of my own scripts, and I would like to keep that portion. However, I would like to remove the portions that include "&index=..." and "&list=...". Is there a way that I could develop it?

I found this while googling it, but not quite sure how I would apply it to this situation, where there are certain sections I want to keep and certain sections I don't.

And what I actually want is for that section to be removed from all the urls entirely when I visit the channel's video page (say here: https://www.youtube.com/user/TeamFourStar/videos). For example, from the channel video page, the URL that should be listed is youtube.com/watch?v=ffDfg2131Oo , none of that crap after it about list. I don't want the page to have to refresh every time I load up a link, I just want to fix the URLs.

Can anyone help me with this?

§
发表于:2014-08-18

how about doing a global link string replacing?

document.body.innerHTML=document.body.innerHTML.replace(/(youtube.com\/watch\?v=.+?&)list=.+?&index=\d+?&/g,"$1");

§
发表于:2014-08-19
编辑于:2014-08-19

Is that all the code I would need in a script? Because I tried out a script that included just that line, and it didn't work.

I'm not much of a script developer.

§
发表于:2014-08-19

It's better not to do bulk innerHTML replacements if you can avoid it. Also, you need the script to monitor for possible clicks on the "More" button that update the page without a full reload.

Could you test: https://greasyfork.org/scripts/4346-youtube-remove-list-from-watch-urls

§
发表于:2014-08-20
Alternates:
https://greasyfork.org/scripts/3433-playlist-remover
https://greasyfork.org/scripts/4298-youtube-url-cleaner

Playlist Remover works perfectly. Thanks Gingerbread Man!

发表回复

登录以发表回复。