Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
317 views
in Technique[技术] by (71.8m points)

javascript - 匹配时重定向和修改Chrome中的网址[关闭](Redirect and modify URLs in Chrome when matched [closed])

Since Youtube is blocked in my country but some sites like https://www.Youtube-nocookie.com/embed/videoID are allowed to stream.(由于YouTube在我的国家/地区遭到封锁,但允许流某些网站,例如https://www.Youtube-nocookie.com/embed/videoID 。)

The Question is when I click on a youtube link, Can it be redirected to www.Youtube-nocookie.com/embed/videoID ;(问题是当我单击youtube链接时,它可以重定向到www.Youtube-nocookie.com/embed/videoID吗 ?) Is it possible with Javascript or Chrome Extension(JavascriptChrome扩展程序是否可能)

I have a sample bookmark javascript that on clicking detects youtube VideoID on current page and redirects to Youtube-Nocookie.com/embed/VideoID.(我有一个示例书签javascript,点击后会在当前页面上检测到youtube VideoID,然后重定向到Youtube-Nocookie.com/embed/VideoID。)

    javascript: 
    var URL = location.href;
    var regExp = /^.*((youtu.be/)|(v/)|(/u/w/)|(embed/)|(watch?))??v?=?([^#&?]*).*/;
    var match = URL.match(regExp); 
        if (match&&match[7].length==11{
          videoID=match[7];
          window.open('https://www.youtube-nocookie.com/embed/'+videoID+'?autoplay=1');
     } else { 
          window.open('https://www.youtube-nocookie.com/embed/');
    }
  ask by Sayyed Dawood translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Test with https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg?hl=en(使用https://chrome.google.com/webstore/detail/switcheroo-redirector/cnmciclhnghalnpfhhleggldniplelbg?hl=zh-CN测试)

I tested it quickly and seems to be able to replace the url to whatever you need.(我对其进行了快速测试,并且似乎能够将url替换为您所需的任何内容。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...