Skip to content

Commit

Permalink
underline video link stylization
Browse files Browse the repository at this point in the history
  • Loading branch information
sumzary committed Oct 14, 2017
1 parent 9b9119e commit e0a3ea2
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 17 deletions.
3 changes: 2 additions & 1 deletion content/optionsWindow.xul
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<prefwindow
id="yt2p-prefwindow"
title="&title.label;"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
buttons="cancel,accept,extra1"
onload="init()"
ondialogaccept="accept()"
Expand Down Expand Up @@ -130,6 +130,7 @@
</preferences>
<checkbox label="&videoLinkChangeEnabled.label;" onclick="onSubPrefsHeadClick(event)" preference="pref_videoLinkChangeEnabled"/>
<radiogroup class="subprefs" preference="pref_videoLinkChangeType">
<radio label="&videoLinkChangeType.stylizeWithRedUnderline.label;" value="3"/>
<radio label="&videoLinkChangeType.stylizeWithRedGlow.label;" value="0"/>
<radio label="&videoLinkChangeType.intoEmbedded.label;" value="1"/>
<radio label="&videoLinkChangeType.intoFil.label;" value="2"/>
Expand Down
22 changes: 16 additions & 6 deletions content/yt2pFrameScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,12 @@
function exec (node) {
if (!node) return false
const a = document.createElement('a')
a.className = 'yt2p-send-override yt2p-stylize'
a.className = 'yt2p-send-override'
if (getPref('videoLinkChangeType') === 0) {
a.classList.add('yt2p-glow')
} else {
a.classList.add('yt2p-underline')
}
a.href = window.location.href
a.onclick = onVideoLinkClick
a.appendChild(node.cloneNode(true))
Expand Down Expand Up @@ -356,7 +361,12 @@
if (changeType === 0 ||
window.doneVideoIds.some(id => id === videoId)) {
const a = document.createElement('a')
a.className = 'yt2p-link yt2p-stylize'
a.className = 'yt2p-link'
if (getPref('videoLinkChangeType') === 0) {
a.classList.add('yt2p-glow')
} else {
a.classList.add('yt2p-underline')
}
a.href = getVideoUrlFromId(videoId)
a.textContent = videoId
a.onclick = onVideoLinkClick
Expand Down Expand Up @@ -399,7 +409,7 @@
const a = document.createElement('a')
a.href = getVideoUrlFromId(videoId)
a.classList.add('yt2p-link')
a.classList.add('yt2p-stylize')
a.classList.add('yt2p-glow')
a.textContent = videoId
a.onclick = onVideoLinkClick
parentElement.replaceChild(a, filElement)
Expand All @@ -419,7 +429,7 @@
// }
const videoId = getVideoIdFromUrl(a.href)
const changeType = getPref('videoLinkChangeType')
if (changeType === 0 ||
if (changeType === 0 || changeType === 3 ||
/ytp-|yt-uix-|yt-simple-/.test(a.className) ||
/c-detail__title/.test(a.parentElement.className) ||
window.doneVideoIds.some(id => id === videoId)) {
Expand All @@ -428,15 +438,15 @@
a.parentElement.insertBefore(newA, a.nextElementSibling)
a.classList.add('yt2p-replaced')
newA.classList.add('yt2p-link')
newA.classList.add('yt2p-stylize')
newA.classList.add(changeType === 0 ? 'yt2p-glow' : 'yt2p-underline')
if (isVideoUrl(a.textContent)) {
newA.textContent = getVideoIdFromUrl(a.href)
}
newA.onclick = onVideoLinkClick
return
}
a.classList.add('yt2p-link')
a.classList.add('yt2p-stylize')
a.classList.add(changeType === 0 ? 'yt2p-glow' : 'yt2p-underline')
if (isVideoUrl(a.textContent) &&
!window.location.href.startsWith('view-source:')) {
a.textContent = getVideoIdFromUrl(a.href)
Expand Down
2 changes: 1 addition & 1 deletion install.rdf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<em:icon64URL>chrome://yt2p/skin/64/yt2p.png</em:icon64URL>
<em:id>[email protected]</em:id>
<em:name>YouTube 2 Player</em:name>
<em:version>2.1</em:version>
<em:version>2.1.1</em:version>
<em:description>Watch YouTube videos in an external player.</em:description>
<em:homepageURL>https://github.com/sumzary/yt2p</em:homepageURL>
<em:creator>Rasmus Riiner</em:creator>
Expand Down
1 change: 1 addition & 0 deletions locale/en-US/optionsWindow.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<!ENTITY embeddedVideoChangeType.intoFil.label "into Fancy Image Links">

<!ENTITY videoLinkChangeEnabled.label "Change regular video links">
<!ENTITY videoLinkChangeType.stylizeWithRedUnderline.label "with a red underline">
<!ENTITY videoLinkChangeType.stylizeWithRedGlow.label "with a red glow">
<!ENTITY videoLinkChangeType.intoEmbedded.label "into embedded videos">
<!ENTITY videoLinkChangeType.intoFil.label "into Fancy Image Links">
Expand Down
1 change: 1 addition & 0 deletions locale/et/optionsWindow.dtd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
<!ENTITY embeddedVideoChangeType.intoFil.label "Piltlinkideks">

<!ENTITY videoLinkChangeEnabled.label "Muuda klippide lingid">
<!ENTITY videoLinkChangeType.stylizeWithRedUnderline.label "punase alljoonega">
<!ENTITY videoLinkChangeType.stylizeWithRedGlow.label "punase helgiga">
<!ENTITY videoLinkChangeType.intoEmbedded.label "embed videoteks">
<!ENTITY videoLinkChangeType.intoFil.label "Piltlinkideks">
Expand Down
29 changes: 20 additions & 9 deletions skin/yt2p.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,24 +55,35 @@
clear: both !important;
display: block !important;
}
.yt2p-stylize:not(.content-link):not(.related-playlist),
.yt2p-stylize.content-link > .title,
.yt2p-stylize.related-playlist > .title {
text-shadow: 1px 1px 3px #E52D27 !important;

.yt2p-underline:not(.content-link):not(.related-playlist),
.yt2p-underline.content-link > .title,
.yt2p-underline.related-playlist > .title {
text-decoration: underline dotted red !important;
}
.yt2p-glow:not(.content-link):not(.related-playlist),
.yt2p-glow.content-link > .title,
.yt2p-glow.related-playlist > .title {
text-shadow: 1px 1px 3px red !important;
text-decoration: none;
}
.yt2p-stylize:not(.ytp-title-link),
.yt2p-stylize.content-link > .title,
.yt2p-stylize.related-playlist > .title {
.yt2p-underline:not(.content-link):not(.related-playlist):hover,
.yt2p-underline.content-link:hover > .title,
.yt2p-underline.related-playlist:hover > .title {
text-decoration-style: solid !important;
}
*:not([class^="c-detail"]) > .yt2p-glow:not(.ytp-title-link),
.yt2p-glow.content-link > .title,
.yt2p-glow.related-playlist > .title {
color: black !important;
}
.yt-simple-endpoint,
ytd-video-meta-block,
.ytd-badge-supported-renderer {
text-shadow: none;
text-decoration-line: none !important;
text-decoration: none !important;
}


.yt2p-clearall,
.yt2p-video,
.yt2p-video-link,
Expand Down

0 comments on commit e0a3ea2

Please sign in to comment.