mirror of
https://github.com/aureliendavid/rsspreview.git
synced 2025-08-23 03:38:44 +00:00
regexp named groups aren't supported until ff 78 (#56)
This commit is contained in:
parent
10790dfede
commit
97ca03cb5d
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "RSSPreview",
|
"name": "RSSPreview",
|
||||||
"version": "3.13",
|
"version": "3.13.1",
|
||||||
"author": "Aurelien David",
|
"author": "Aurelien David",
|
||||||
"homepage_url": "https://github.com/aureliendavid/rsspreview",
|
"homepage_url": "https://github.com/aureliendavid/rsspreview",
|
||||||
|
|
||||||
|
@ -382,13 +382,13 @@
|
|||||||
// YouTube's canonical channel URLs look like /channel/AlphaNumericID
|
// YouTube's canonical channel URLs look like /channel/AlphaNumericID
|
||||||
// It also supports named channels of the form /c/MyChannelName
|
// It also supports named channels of the form /c/MyChannelName
|
||||||
// Match on both of these to autodetect channel feeds on either URL
|
// Match on both of these to autodetect channel feeds on either URL
|
||||||
let idPattern = /channel\/(?<channelId>[a-zA-Z0-9_-]+)/;
|
let idPattern = /channel\/([a-zA-Z0-9_-]+)/;
|
||||||
let namePattern = /(?:c|user)\/[a-zA-Z0-9_-]+/;
|
let namePattern = /(?:c|user)\/[a-zA-Z0-9_-]+/;
|
||||||
let urlPattern = new RegExp(`${idPattern.source}|${namePattern.source}`);
|
let urlPattern = new RegExp(`${idPattern.source}|${namePattern.source}`);
|
||||||
if (document.URL.match(urlPattern)) {
|
if (document.URL.match(urlPattern)) {
|
||||||
let feeds = {};
|
let feeds = {};
|
||||||
let canonicalUrl = document.querySelector("link[rel='canonical']").href;
|
let canonicalUrl = document.querySelector("link[rel='canonical']").href;
|
||||||
let channelId = canonicalUrl.match(idPattern).groups.channelId;
|
let channelId = canonicalUrl.match(idPattern)[1];
|
||||||
let url = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`;
|
let url = `https://www.youtube.com/feeds/videos.xml?channel_id=${channelId}`;
|
||||||
let title = document.title;
|
let title = document.title;
|
||||||
feeds[url] = title;
|
feeds[url] = title;
|
||||||
|
Loading…
Reference in New Issue
Block a user