Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Remove analytics and donate/bug links
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Nov 14, 2021
1 parent 9e470d3 commit b886a03
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 47 deletions.
56 changes: 12 additions & 44 deletions js/noplugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,45 +16,25 @@ const youtubeRegex = /.*(?:youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).
// Regex for detecting livestream links https://regex101.com/r/So4qWf/1
const streamDetectRegex = /(\:\d{1,}$)|(\/$)/gm

// Function for sending events to Google Analytics
function sendEvent(eventCategory, eventAction, eventLabel = '') {
return new Promise(async function (resolve) {
// Get UUID from storage
chrome.storage.local.get(function (data) {
var uuid = data.uuid
// Send Fetch data
fetch('https://www.google-analytics.com/collect', {
method: 'POST',
body: 'v=1&tid=UA-59452245-9&cid=' + uuid + '&t=event&ec=' + encodeURIComponent(eventCategory) + '&ea=' + encodeURIComponent(eventAction) + '&el=' + encodeURIComponent(eventLabel)
}).then(function (data) {
resolve()
}).catch(function (err) {
console.log('Analytics error:', err)
resolve()
})
})
})
}

// Function for adding tooltip to replaced elements
function addTooltip(element) {
// Generate content
var popupContent = document.createElement('div')
popupContent.innerText = 'NoPlugin has loaded this legacy content.'
// Add bug reporting button
var popupBtn = document.createElement('button')
popupBtn.innerText = 'Report Bug'
popupBtn.addEventListener('click', function () {
createPopup(chrome.extension.getURL("bugreport.html") + '?url=' + encodeURIComponent(window.location))
})
popupContent.appendChild(popupBtn)
// var popupBtn = document.createElement('button')
// popupBtn.innerText = 'Report Bug'
// popupBtn.addEventListener('click', function () {
// createPopup(chrome.extension.getURL("bugreport.html") + '?url=' + encodeURIComponent(window.location))
// })
// popupContent.appendChild(popupBtn)
// Add donate button
var popupBtn = document.createElement('button')
popupBtn.innerText = 'Support NoPlugin'
popupBtn.addEventListener('click', function () {
window.open('https://www.patreon.com/corbindavenport', '_blank')
})
popupContent.appendChild(popupBtn)
// var popupBtn = document.createElement('button')
// popupBtn.innerText = 'Support NoPlugin'
// popupBtn.addEventListener('click', function () {
// window.open('https://www.patreon.com/corbindavenport', '_blank')
// })
// popupContent.appendChild(popupBtn)
// Show popup
tippy(element, {
content: popupContent,
Expand Down Expand Up @@ -202,7 +182,6 @@ function parsePlaylist(url) {
if (url.endsWith('.asx')) {
// Advanced Stream Redirector (ASX) files are in XML format
// Documentation: http://www.streamalot.com/playlists.shtml
sendEvent('Playlist Load', 'ASX')
var asx = document.createElement('div')
asx.innerHTML = DOMPurify.sanitize(xhr.responseText)
// Check playlist is valid
Expand Down Expand Up @@ -230,7 +209,6 @@ function parsePlaylist(url) {
} else if (url.endsWith('.wpl')) {
// Windows Media Player Playlist files are in XML format
// Documentation: https://en.wikipedia.org/wiki/Windows_Media_Player_Playlist
sendEvent('Playlist Load', 'WPL')
var wpl = document.createElement('div')
wpl.innerHTML = DOMPurify.sanitize(xhr.responseText)
// Check playlist is valid
Expand Down Expand Up @@ -258,7 +236,6 @@ function parsePlaylist(url) {
} else if (url.endsWith('.qtl')) {
// QuickTime Link files are in XML format
// Documentation: https://stackoverflow.com/a/25399903/2255592 and http://www.streamalot.com/playlists.shtml
sendEvent('Playlist Load', 'QTL')
var qtl = document.createElement('div')
qtl.innerHTML = DOMPurify.sanitize(xhr.responseText)
// Check playlist is valid
Expand Down Expand Up @@ -286,7 +263,6 @@ function parsePlaylist(url) {
} else if (url.endsWith('.m3u')) {
// M3U files are just lists with links to files
// Documentation: https://en.wikipedia.org/wiki/M3U#Examples and http://www.streamalot.com/playlists.shtml
sendEvent('Playlist Load', 'M3U')
var m3u = xhr.responseText.split('\n')
// Filter out empty lines and comments
m3u = m3u.filter(s => s.replace(/\s+/g, '').length !== 0)
Expand Down Expand Up @@ -366,7 +342,6 @@ async function injectPlayer(object, media, mediaUrl) {
return
} else if (mediaUrl.includes('youtube.com/v/')) {
// Old Flash-based YouTube embed
sendEvent('Media Load', 'YouTube Flash')
var frame = document.createElement('iframe')
frame.setAttribute('class', media.cssClass)
frame.id = media.id
Expand All @@ -380,7 +355,6 @@ async function injectPlayer(object, media, mediaUrl) {
addTooltip(frame)
} else if (mediaUrl.includes('TwitchPlayer.swf')) {
// Old Flash-based Twitch embed
sendEvent('Media Load', 'Twitch.tv Flash')
var container = document.createElement('div')
container.setAttribute('class', 'noplugin ' + media.cssClass)
container.id = media.id
Expand Down Expand Up @@ -435,7 +409,6 @@ async function injectPlayer(object, media, mediaUrl) {
}
} else if (mediaUrl.includes('vimeo.com/moogaloop.swf')) {
// Old Flash-based Vimeo embed
sendEvent('Media Load', 'Vimeo Flash')
var frame = document.createElement('iframe')
frame.setAttribute('class', media.cssClass)
frame.id = media.id
Expand All @@ -449,7 +422,6 @@ async function injectPlayer(object, media, mediaUrl) {
addTooltip(frame)
} else if (mediaUrl.includes('zplayer.swf')) {
// Zanorg Player: https://radio.zanorg.com/zplayer_eng.htm
sendEvent('Media Load', 'Zanorg Player')
var mediaPlayer = document.createElement('audio')
mediaPlayer.setAttribute('controlsList', 'nofullscreen nodownload')
mediaPlayer.id = media.id
Expand Down Expand Up @@ -492,7 +464,6 @@ async function injectPlayer(object, media, mediaUrl) {
addTooltip(frame)
} else if (mediaUrl.includes('mms://') || mediaUrl.includes('rtsp://') || mediaUrl.endsWith('.ram') || streamDetectRegex.test(mediaUrl)) {
// This is a media stream
sendEvent('Media Load', 'Misc Stream')
var container = document.createElement('div')
container.setAttribute('class', 'noplugin ' + media.cssClass)
container.id = media.id
Expand Down Expand Up @@ -524,7 +495,6 @@ async function injectPlayer(object, media, mediaUrl) {
console.log('Replaced playlist embed:', media)
} else if (mediaUrl.includes('.swf')) {
// This is a Flash Player file
sendEvent('Media Load', 'Misc Flash', getFileName(mediaUrl))
var container = document.createElement('div')
container.setAttribute('class', 'noplugin ' + media.cssClass)
container.id = media.id
Expand Down Expand Up @@ -619,7 +589,6 @@ async function injectPlayer(object, media, mediaUrl) {
}
} else if ((mediaUrl.endsWith('.mp3')) || (mediaUrl.endsWith('.m4a')) || (mediaUrl.endsWith('.wav'))) {
// This is an audio file
sendEvent('Media Load', 'Misc Audio')
var mediaPlayer = document.createElement('audio')
mediaPlayer.setAttribute('controlsList', 'nofullscreen nodownload')
mediaPlayer.id = media.id
Expand All @@ -637,7 +606,6 @@ async function injectPlayer(object, media, mediaUrl) {
addTooltip(mediaPlayer)
} else {
// Attempt to play other formats (MP4, FLV, QuickTime, etc.) in the browser
sendEvent('Media Load', 'Misc Media')
var container = document.createElement('div')
container.setAttribute('class', 'noplugin ' + media.cssClass)
container.id = media.id
Expand Down
7 changes: 4 additions & 3 deletions welcome.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<div class="jumbotron">
<div class="container">
<h1>Welcome to NoPlugin <span class="version"></span>!</h1>
<p>You have been updated to the latest version of the NoPlugin extension. NoPlugin 7.0 improves support for Adobe Flash embeds, adds a compatibility mode in the right-click menu, updates the UI, and much more! Read all about it <a href="https://blog.corbin.io/post/638155534677245952/introducing-noplugin-70" target="_blank">here</a>.</p>
<p>NoPlugin is no longer under active development. See <a href="https://blog.corbin.io/post/667791666532483072/ending-development-of-noplugin" target="_blank">this blog post</a> for more information.</p>
</div>
</div>

Expand All @@ -32,7 +32,8 @@ <h2>How NoPlugin works</h2>
<button type="button" class="btn btn-primary flash-btn">Download Adobe Flash Projector</button>
</p>
</div>
<div class="col-md-4">
<!-- This is hidden now that NoPlugin is no longer developed -->
<div class="col-md-4" style="display: none;">
<p>
<h2>Donate</h2>
</p>
Expand All @@ -54,7 +55,7 @@ <h2>Having issues?</h2>
<hr>

<footer>
<p>NoPlugin uses code from <a href="https://getbootstrap.com/" target="_blank">Bootstrap</a>, <a href="https://popper.js.org/" target="_blank">Popper</a>, <a href="https://atomiks.github.io/tippyjs/" target="_blank">Tippy</a>, and <a href="https://github.com/cure53/DOMPurify" target="_blank">DOMPurify</a>. You can find NoPlugin's source code <a href="https://github.com/corbindavenport/noplugin" target="_blank">on GitHub</a>, under the GPLv3 license. NoPlugin uses Google Analytics to collect anonymous usage data, see the <a href="https://github.com/corbindavenport/noplugin/wiki/Privacy-Policy" target="_blank">privacy policy</a> for more information.</p></p>
<p>NoPlugin uses code from <a href="https://getbootstrap.com/" target="_blank">Bootstrap</a>, <a href="https://popper.js.org/" target="_blank">Popper</a>, <a href="https://atomiks.github.io/tippyjs/" target="_blank">Tippy</a>, and <a href="https://github.com/cure53/DOMPurify" target="_blank">DOMPurify</a>. You can find NoPlugin's source code <a href="https://github.com/corbindavenport/noplugin" target="_blank">on GitHub</a>, under the GPLv3 license.</p>
</footer>
</div>

Expand Down

0 comments on commit b886a03

Please sign in to comment.