Skip to content

Commit

Permalink
Make it work on version 1.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
guicheffer committed Jun 7, 2018
1 parent ddf152c commit 0c24a99
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 102 deletions.
7 changes: 7 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[*]
charset = utf-8
indent_style = space
indent_size = 2
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ help:
dist-chrome: ## makes a development mode plugin for chrome
mkdir -p dist/chrome
cp chrome/manifest.json dist/chrome
cp -R lib/* dist/chrome
cp -R chrome/lib/* dist/chrome/lib
zip dist/chrome.zip dist/chrome

dist: dist-chrome
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Nuketube: Remove distractions from youtube
# 💥 Nuketube: Remove distractions from youtube

Browser extensions to remove all the elements from a youtube video page but the video.

Expand Down
File renamed without changes.
File renamed without changes
20 changes: 20 additions & 0 deletions chrome/lib/background.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 💥 Nuketube main script
* Copyright 2018 @ guicheffer.me
*
* Plugin for chrome/firefox which removes all the elements from the page and let only the youtube video tag plays
*
*/

const urlRegex = /^https?:\/\/(?:[^./?#]+\.)?youtube\.com/
const initialize = (domContent) => {
console.log(`I received the following DOM content:\n ${domContent}`)
}

chrome.browserAction.onClicked.addListener((tab) => {
if (urlRegex.test(tab.url)) {
chrome.tabs.executeScript({
file: './lib/content.js'
}) ;
}
})
55 changes: 55 additions & 0 deletions chrome/lib/content.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 💥 Nuketube content script
* Copyright 2018 @ guicheffer.me
*
* Plugin for chrome/firefox which removes all the elements from the page and let only the youtube video tag plays
*
*/

// Adds query values into a global "getQueryStrings" variable
if (!window.getQueryStrings) {
window.getQueryStrings = () => {
const itself = {}
const fullQs = window.location.search.substring(1)
const params = fullQs.split('&')

for (let i=0; i<params.length; i++) {
const pair = params[i].split('=')

if (typeof itself[pair[0]] === 'undefined') {
itself[pair[0]] = pair[1]
} else if (typeof itself[pair[0]] === 'string') {
const arr = [ itself[pair[0]], pair[1] ]
itself[pair[0]] = arr
} else {
itself[pair[0]].push(pair[1])
}
}

return itself
}
}

(() => {
const queryStrings = getQueryStrings()

if (!queryStrings.v || typeof queryStrings.v === 'undefined') return window.alert('💥 No youtube video found! 😭')

const isThereAFullScreenAlready = document.querySelector('#iframe-video-nuketube')
if (isThereAFullScreenAlready) return window.location.reload()

const bodyElement = document.querySelector('body')
const iframeStyleInline = 'position: absolute;'
bodyElement.innerHTML = ''

const cloneVideoElement = document.createElement( 'div' )
cloneVideoElement.innerHTML = `
<iframe id="iframe-video-nuketube" width="100%" height="100%"
src="https://www.youtube.com/embed/${queryStrings.v}?autoplay=1"
style="${iframeStyleInline}"
frameborder="0" allowfullscreen autoplay>
</iframe>
`

bodyElement.appendChild(cloneVideoElement)
})()
26 changes: 12 additions & 14 deletions chrome/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@
"manifest_version": 2,

"name": "Nuketube",
"description": "Plugin for chrome which removes all the elements from the page and let only the youtube video tag plays — Edit",
"version": "0.0.1",
"description": "Plugin for chrome which removes all the elements from the page and let only the youtube video tag plays",
"version": "1.0.0",

"background": {
"scripts": ["background.js"]
"persistent": false,
"scripts": ["./lib/background.js"]
},

"icons": {
"16" : "icon.png",
"48" : "icon.png",
"128" : "icon.png"
"browser_action": {
"default_icon": "./images/icon.png",
"default_title": "👉🏼 Click here to let only the youtube video plays!"
},

"browser_action": {
"default_icon": "icon.png",
"default_title": "Click here to let only the video plays!"
"icons": {
"16" : "./images/icon.png",
"48" : "./images/icon.png",
"128" : "./images/icon.png"
},

"permissions": [
"activeTab",
"https://www.youtube.com/*"
]
"permissions": ["activeTab", "https://www.youtube.com/*"]
}
5 changes: 0 additions & 5 deletions lib/background.js

This file was deleted.

4 changes: 0 additions & 4 deletions lib/jquery.min.js

This file was deleted.

77 changes: 0 additions & 77 deletions lib/script.js

This file was deleted.

0 comments on commit 0c24a99

Please sign in to comment.