Make sure the user doesn't mark URL types that do not represent a user
This commit is contained in:
parent
05766819b1
commit
00c5a87689
@ -148,6 +148,64 @@ function openHelp() {
|
||||
})
|
||||
}
|
||||
|
||||
var badIdentifiers = {};
|
||||
[
|
||||
'facebook.com/a',
|
||||
'facebook.com/ad_campaign',
|
||||
'facebook.com/ads',
|
||||
'facebook.com/bookmarks',
|
||||
'facebook.com/buddylist.php',
|
||||
'facebook.com/bugnub',
|
||||
'facebook.com/comment',
|
||||
'facebook.com/composer',
|
||||
'facebook.com/events',
|
||||
'facebook.com/findfriends',
|
||||
'facebook.com/friends',
|
||||
'facebook.com/legal',
|
||||
'facebook.com/pg',
|
||||
'facebook.com/page',
|
||||
'facebook.com/fundraisers',
|
||||
'facebook.com/games',
|
||||
'facebook.com/groups',
|
||||
'facebook.com/help',
|
||||
'facebook.com/home.php',
|
||||
'facebook.com/intl',
|
||||
'facebook.com/jobs',
|
||||
'facebook.com/l.php',
|
||||
'facebook.com/language.php',
|
||||
'facebook.com/local_surface',
|
||||
'facebook.com/logout.php',
|
||||
'facebook.com/mbasic',
|
||||
'facebook.com/menu',
|
||||
'facebook.com/messages',
|
||||
'facebook.com/nfx',
|
||||
'facebook.com/notes',
|
||||
'facebook.com/notifications.php',
|
||||
'facebook.com/notifications',
|
||||
'facebook.com/nt',
|
||||
'facebook.com/pages',
|
||||
'facebook.com/people',
|
||||
'facebook.com/photo.php',
|
||||
'facebook.com/policies',
|
||||
'facebook.com/privacy',
|
||||
'facebook.com/reactions',
|
||||
'facebook.com/salegroups',
|
||||
'facebook.com/search',
|
||||
'facebook.com/settings',
|
||||
'facebook.com/story.php',
|
||||
'facebook.com/ufi',
|
||||
'reddit.com/r/all',
|
||||
'reddit.com/r/popular',
|
||||
'twitter.com/hashtag',
|
||||
'twitter.com/i',
|
||||
'twitter.com/search',
|
||||
'twitter.com/settings',
|
||||
'twitter.com/threadreaderapp',
|
||||
'youtube.com/watch',
|
||||
].forEach(x => badIdentifiers[x] = true);
|
||||
|
||||
|
||||
|
||||
browser.contextMenus.onClicked.addListener(function (info, tab) {
|
||||
if (info.menuItemId == 'help') {
|
||||
openHelp();
|
||||
@ -163,6 +221,9 @@ browser.contextMenus.onClicked.addListener(function (info, tab) {
|
||||
debug: overrides.debug
|
||||
}, null, response => {
|
||||
if (!response.identifier) return;
|
||||
if (badIdentifiers[response.identifier] && response.mark) return;
|
||||
if (response.debug && /^facebook\.com\/[a-zA-Z]/.test(response.identifier))
|
||||
alert('Note: could not find numeric id for ' + response.identifier);
|
||||
response.tabId = tab.id;
|
||||
saveLabel(response);
|
||||
})
|
||||
|
@ -406,12 +406,16 @@ function getIdentifierInternal(urlstr) {
|
||||
return 'facebook.com/' + (s.story_fbid || s.set || s.story_fbid || s._ft_ || s.ft_id || s.id || takeFirstPathComponents(p, p.startsWith('/groups/') ? 2 : 1).substring(1));
|
||||
}
|
||||
if (isHostedOn(host, 'reddit.com')) {
|
||||
return 'reddit.com' + takeFirstPathComponents(url.pathname.replace('/u/', '/user/'), 2).toLowerCase();
|
||||
var pathname = url.pathname.replace('/u/', '/user/');
|
||||
if (!pathname.startsWith('/user/') && !pathname.startsWith('/r/')) return null;
|
||||
return 'reddit.com' + takeFirstPathComponents(pathname, 2).toLowerCase();
|
||||
}
|
||||
if (isHostedOn(host, 'twitter.com')) {
|
||||
return 'twitter.com' + takeFirstPathComponents(url.pathname, 1).toLowerCase();
|
||||
}
|
||||
if (isHostedOn(host, 'youtube.com')) {
|
||||
var pathname = url.pathname;
|
||||
if (!pathname.startsWith('/user/') && !pathname.startsWith('/channel/')) return null;
|
||||
return 'youtube.com' + takeFirstPathComponents(url.pathname, 2);
|
||||
}
|
||||
if (isHostedOn(host, 'disqus.com') && url.pathname.startsWith('/by/')) {
|
||||
@ -431,7 +435,7 @@ function getIdentifierInternal(urlstr) {
|
||||
return null;
|
||||
}
|
||||
if (isHostedOn(host, 'wikipedia.org') || isHostedOn(host, 'rationalwiki.org')) {
|
||||
if (url.hash) return null;
|
||||
if (url.hash || url.pathname.includes(':')) return null;
|
||||
if (url.pathname.startsWith('/wiki/')) return 'wikipedia.org' + takeFirstPathComponents(url.pathname, 2);
|
||||
else return null;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user