Commit d8c1a09c authored by sebaro's avatar sebaro

Code, design, options changes/fixes

parent 1587c56b
......@@ -3,6 +3,9 @@
/* SaveTube Changelog */
#2019.12.05
- Script: new design, options fixes
#2019.09.21
- fixes video title
......
......@@ -9,8 +9,14 @@ SaveTube is a browser user script for downloading videos from video websites.
#### Mozilla (Firefox, Seamonkey, IceWeasel, IceCat, TenFourFox etc):
- with Greasemonkey add-on:
> https://addons.mozilla.org/firefox/addon/greasemonkey
- with Tampermonkey add-on:
> https://addons.mozilla.org/en-US/firefox/addon/tampermonkey/
> https://www.tampermonkey.net/?browser=firefox
- with Violentmonkey add-on:
> https://addons.mozilla.org/firefox/addon/violentmonkey/
> https://violentmonkey.github.io/get-it/
- with Scriptish add-on:
> https://addons.mozilla.org/firefox/addon/scriptish
> https://github.com/scriptish/scriptish
- WebExtensions add-on:
> https://addons.mozilla.org/firefox/addon/savetube
......@@ -18,25 +24,28 @@ SaveTube is a browser user script for downloading videos from video websites.
- save the script and drag & drop it on the extensions page
- with Tampermonkey add-on:
> https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
> https://www.tampermonkey.net/?browser=chrome
- with Violentmonkey add-on:
> https://chrome.google.com/webstore/detail/violentmonkey/jinjaccalgkegednnccohejagnlnfdag
> https://violentmonkey.github.io/get-it/
- WebExtensions add-on:
> https://chrome.google.com/webstore/detail/savetube/olnfnfnjjobemjofpilijbdnmojefabe
> http://sebaro.pro/savetube/files/savetube.crx
#### Opera:
- for versions <= 12 no add-on needed, just place the script in the JavaScript files directory
- for versions <= 12 download and save the script in the JavaScript files directory (Settings/Preferences/Advanced/Content/JavaScript Options.../User JavaScript folder) and enable "User JavaScript on HTTPS" in "opera:config".
- with Violentmonkey extension:
> https://addons.opera.com/en/extensions/details/violent-monkey
> https://violentmonkey.github.io/get-it/
- with Tampermonkey extension:
> https://addons.opera.com/en/extensions/details/tampermonkey-beta
> https://www.tampermonkey.net/?browser=opera
#### Safari:
- for versions < 5.1 with GreaseKit add-on:
> http://safariaddons.com/en-US/safari/addon/43
- for all versions (?) with NinjaKit add-on:
> http://d.hatena.ne.jp/os0x/20100612/1276330696
- as bookmarklet with Geekmonkey add-on:
> http://surber.us/2006/04/14/geekmonkey
- for versions < 5.0.1 with NinjaKit add-on:
> http://os0x.hatenablog.com/entry/20100612/1276330696
- for versions >= 6 with Tampermonkey add-on:
> https://www.tampermonkey.net/?browser=safari
#### Epiphany:
- with the Greasemonkey extension from Epiphany extensions
......@@ -52,26 +61,21 @@ SaveTube is a browser user script for downloading videos from video websites.
> http://extension.maxthon.com/detail/index.php?view_id=1680
- with Tampermonkey Chrome extension:
> https://chrome.google.com/webstore/detail/tampermonkey/dhdgffkkebhmkfjojejmpbldmpobfkfo
> https://www.tampermonkey.net/?browser=chrome
- Maxthon extension:
> http://extension.maxthon.com/detail/index.php?view_id=2816
#### Internet Explorer:
- with IE7Pro extension:
> http://ie7pro.com
- IE11:
> https://sourceforge.net/projects/trixiewpf45
## Options
#### Autoget:
- Click 'Autoget' button to turn autoget on/off. If it's on, the video download will start when the video page is loaded or when a new video format is selected.
#### Definition (SD, HD etc)
- Select the default (highest) video definition.
#### Definition (SD, HD etc):
- Click this button to change the default video definition.
#### Container (MP4, WebM etc)
- Select the default video container.
#### Container (MP4, WebM etc):
- Click this button to change the default video container.
#### Autoget:
- Enable/disable video autodownload. If it's on, the video download will start when the video page is loaded or when a new video format is selected.
#### MPEG-DASH (MD):
- Click this button to enable/disable MPEG-DASH streams (video with audio) download. It requires an external application for muxing the audio and video streams, see http://sebaro.pro/savetube
- Enable/disable DASH streams (video with audio) download. It requires an external application for muxing the audio and video streams, see http://sebaro.pro/savetube
This diff is collapsed.
// ==UserScript==
// @name SaveTube+
// @version 2018.11.12
// @version 2019.12.05
// @description Download videos from web sites.
// @author sebaro
// @namespace http://sebaro.pro/savetube
......@@ -16,7 +16,7 @@
/*
Copyright (C) 2014 - 2018 Sebastian Luncan
Copyright (C) 2014 - 2019 Sebastian Luncan
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
......@@ -43,11 +43,12 @@
// ==========Variables========== //
// Userscript
var userscript = 'SaveTube';
// Contact
var userscript = 'SaveTube+';
var website = 'http://sebaro.pro/savetube';
var contact = 'http://sebaro.pro/contact';
// Saver
var panelHeight = 30;
// ==========Fixes========== //
......@@ -55,6 +56,15 @@ var contact = 'http://sebaro.pro/contact';
if (window.top && window.top != window.self) return;
// ==========Functions========== //
function styleMyElement(obj, styles) {
for (var stylekey in styles) {
obj.style[stylekey] = styles[stylekey];
}
}
// ==========Websites========== //
/* Page Source */
......@@ -73,9 +83,11 @@ var patterns = [
'\'(http[^\']*?\\.(mp4|flv|webm|m3u8).*?)\''
];
var exclude = '(thumb|\\.jpg|\\.png|\\.gif|\\.htm|format=|\\/\\/[^\\/]*?(mp4|flv|webm|m3u8)|(mp4|flv|webm|m3u8)[0-9a-zA-Z])';
/* Video Matcher */
var pattern, matches, matcher, video, type;
var links = '';
var links = [];
for (var i = 0; i < patterns.length; i++) {
pattern = new RegExp(patterns[i], 'g');
matches = source.match(pattern);
......@@ -84,63 +96,48 @@ for (var i = 0; i < patterns.length; i++) {
matcher = matches[v].match(patterns[i]);
video = (matcher) ? matcher[1] : null;
if (video) {
video = video.replace(/\\/g, '');
if (video.indexOf('%') != -1) video = unescape(video);
if (video.indexOf('\\u00') != -1) video = video.replace(/\\u002F/g, '/').replace(/\\u0026/g, '&');
if (video.indexOf('&amp;') != -1) video = video.replace(/&amp;/g, '&');
if (video.indexOf('http') == 0 && !video.match(/(thumb|\.jpg|\.png|\.gif|\.htm|format=|\/\/[^\/]*?(mp4|flv|webm|m3u8))/)) {
if (video.indexOf('.mp4') != -1) type = 'MP4';
else if (video.indexOf('.flv') != -1) type = 'FLV';
else if (video.indexOf('.webm') != -1) type = 'WebM';
else if (video.indexOf('.m3u8') != -1) type = 'M3U8';
else type = 'Video';
if (links.indexOf(video) == -1) links += ' <a href="' + video + '" style="color:#2C72C7">' + type + '</a>';
video = video.replace(/\\/g, '');
if (video.indexOf('http') == 0 && !video.match(exclude)) {
if (links.indexOf(video) == -1) links.push(video);
}
}
}
}
}
if (links) {
if (links.length > 0) {
var panel = document.createElement('div');
panel.style.position = 'fixed';
panel.style.bottom = '0px';
panel.style.right = '25px';
panel.style.zIndex = '2000000000';
panel.style.color = '#336699';
panel.style.backgroundColor = '#FFFFFF';
panel.style.padding = '5px 5px 10px 5px';
panel.style.fontSize = '12px';
panel.style.fontWeight = 'bold';
panel.style.borderLeft = '3px solid #EEEEEE';
panel.style.borderRight = '3px solid #EEEEEE';
panel.style.borderTop = '3px solid #EEEEEE';
panel.style.borderRadius = '5px 5px 0px 0px';
panel.innerHTML = '<a href="' + contact + '" style="color:#336699; font-weight:bold; text-decoration:none">' + userscript + '</a>: ' + links;
var button = document.createElement('div');
button.innerHTML = '<';
button.style.height = '12px';
button.style.border = '1px solid #CCCCCC';
button.style.borderRadius = '3px';
button.style.padding = '0px 5px';
button.style.display = 'inline';
button.style.color = '#CCCCCC';
button.style.fontSize = '12px';
button.style.textShadow = '0px 1px 1px #CCCCCC';
button.style.cursor = 'pointer';
button.style.marginLeft = '10px';
button.addEventListener('click', function() {
if (panel.style.right == '25px') {
panel.style.left = '25px';
panel.style.right = 'auto';
button.innerHTML = '>';
}
else {
panel.style.left = 'auto';
panel.style.right = '25px';
button.innerHTML = '<';
}
}, false);
panel.appendChild(button);
styleMyElement(panel, {position: 'fixed', height: panelHeight + 'px', backgroundColor: '#FFFFFF', padding: '0px 10px 5px 10px', bottom: '0px', right: '25px', lineHeight: (panelHeight - 2) + 'px', zIndex: '2000000000', borderTop: '1px solid #CCCCCC', borderLeft: '1px solid #CCCCCC', borderRight: '1px solid #CCCCCC', borderRadius: '5px 5px 0px 0px', boxSizing: 'content-box'});
document.body.appendChild(panel);
var logo = document.createElement('div');
styleMyElement(logo, {display: 'inline-block', color: '#32d132', fontSize: '14px', fontWeight: 'bold', border: '1px solid #32d132', borderRadius: '3px', padding: '0px 4px', marginRight: '10px', lineHeight: 'normal', verticalAlign: 'middle'});
panel.appendChild(logo);
logo.innerHTML = userscript;
var menu = document.createElement('select');
styleMyElement(menu, {width: '270px', display: 'inline-block', fontSize: '14px', fontWeight: 'bold', padding: '0px 3px', overflow: 'hidden', border: '1px solid #CCCCCC', color: '#777777', backgroundColor: '#FFFFFF', lineHeight: 'normal', verticalAlign: 'middle', cursor: 'pointer'});
var option;
for (var i = 0; i < links.length; i++) {
option = document.createElement('option');
styleMyElement(option, {fontSize: '14px', fontWeight: 'bold', cursor: 'pointer'});
option.value = links[i];
option.innerHTML = links[i].substr(0, 50) + '...';
option.title = links[i];
menu.appendChild(option);
}
panel.appendChild(menu);
var linkb = document.createElement('div');
styleMyElement(linkb, {display: 'inline-block', color: '#777777', fontSize: '14px', fontWeight: 'bold', padding: '0px 4px', verticalAlign: 'middle', marginLeft: '5px', cursor: 'pointer'});
panel.appendChild(linkb);
var link = document.createElement('a');
styleMyElement(link, {color: '#777777', textDecoration: 'underline'});
link.innerHTML = '[Link]';
link.href = links[0];
linkb.appendChild(link);
menu.addEventListener('change', function() {
link.href = this.value;
}, false);
}
})();
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment