-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathhighlight_digg.user.js
More file actions
49 lines (45 loc) · 1.33 KB
/
Copy pathhighlight_digg.user.js
File metadata and controls
49 lines (45 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// ==UserScript==
// @name Digg Highlighter
// @description Highlight new stories on Digg
// @author chocolateboy
// @copyright chocolateboy
// @version 1.2.0
// @namespace https://github.com/chocolateboy/userscripts
// @license GPL
// @include https://digg.com/
// @require https://code.jquery.com/jquery-3.6.0.slim.min.js
// @require https://cdn.jsdelivr.net/gh/chocolateboy/jquery-highlighter@63adeb7dea43c47e210fd17b0589e648239e97f0/dist/highlighter.min.js
// @grant GM_deleteValue
// @grant GM_getValue
// @grant GM_listValues
// @grant GM_registerMenuCommand
// @grant GM_setValue
// ==/UserScript==
const PROMO_CHANNELS = [
'/advertising',
'apps-we-digg',
'digg-pick',
'digg-store',
'gift-guides',
'promotion',
]
const PROMO_SELECTOR = PROMO_CHANNELS
.map(name => {
const href = name.startsWith('/') ? name : `/channel/${name}`
return `a[itemprop="keywords"][href="${href}"]`
})
.join(', ')
/**
* @this {JQuery<HTMLElement>}
*/
function isArticle () {
return !$(this).find(PROMO_SELECTOR).length
}
$.highlight({
ttl: { days: 4 },
item () {
return $('article[data-id]').has('[itemprop="headline"]').filter(isArticle)
},
target: '[itemprop="headline"]',
id: 'data-id'
})