Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.4 #4

Merged
merged 11 commits into from
Nov 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
*.zip
node_modules/
.vscode/
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ On 31/Oct/2017, Google has reinstated the extension, which is available at: http

It is a cut-down version ([original extension page](https://weibomiaopai.com/chrome-extension/)) that does not support Youtube download and all other adult sites. *I am sorry*. But you are still able to use the web version: https://weibomiaopai.com/download-video-parser.php

# Unit Tests
Unit tests are based on `mocha` and `chai`. Run all tests: `npm run build`.

# Webpack
Using `npm run build` to pack to `dist\*`

# 中文

---------------
博文: [说说我那复活的视频下载插件](https://justyy.com/archives/5615)

这个[插件](https://weibomiaopai.com/chrome/)不支持 Youtube, 也不支持其它一些成人站点,因为GOOGLE规定不可以。
但你可以直接在WEB里下载:https://weibomiaopai.com/
这个[插件](https://weibomiaopai.com/chrome/)不支持 Youtube, 也不支持其它一些成人站点,因为GOOGLE规定不可以。 但你可以直接在WEB里下载:https://weibomiaopai.com/

# Chrome浏览器扩展下载地址
简易下载视频插件: https://chrome.google.com/webstore/detail/simple-video-download-hel/ilcdiicigjaccgipndigcenjieedjohj
Expand Down
1 change: 1 addition & 0 deletions video-url-parser/dist/dist.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 21 additions & 17 deletions video-url-parser/js/background.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
switch (message.type) {
case "bglog":
console.log(message.obj);
break;
}
return true;
});
(function() {
"use strict";

chrome.runtime.onMessage.addListener(function(message, sender, sendResponse) {
switch (message.type) {
case "bglog":
console.log(message.obj);
break;
}
return true;
});

chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == "install") {
//call a function to handle a first install
console.log("onInstalled: Thank you! https://weibomiaopai.com");
} else if (details.reason == "update") {
//call a function to handle an update
console.log("new version available: https://weibomiaopai.com");
}
});
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == "install") {
//call a function to handle a first install
console.log("onInstalled: Thank you! https://weibomiaopai.com");
} else if (details.reason == "update") {
//call a function to handle an update
console.log("new version available: https://weibomiaopai.com");
}
});
})();
23 changes: 21 additions & 2 deletions video-url-parser/js/constants.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
'use strict';
/* jshint -W097 */
"use strict";

let max_url_length = 95;
const max_url_length = 95;
const steemit_domains = [
'steemit.com',
'steemkr.com',
'cnsteem.com',
'utopian.io',
'staging.busy.org',
'steemhunt.com',
'mspsteem.com',
'steemdb.com',
'busy.org',
'steemd.com'
];

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = {
max_url_length, steemit_domains
};
}
84 changes: 75 additions & 9 deletions video-url-parser/js/functions.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
'use strict';
/* jshint -W097 */
/* jshint -W117 */
"use strict";

// truncate the long URLs.
String.prototype.trim2 = function (length) {
return this.length > length ? this.substring(0, length) + "..." : this;
}
};

const getChromeVersion = () => {
let raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./);
return raw ? parseInt(raw[2], 10) : false;
}
};

const getLocalIPs = (callback) => {
let ips = [];
Expand Down Expand Up @@ -37,14 +40,14 @@ const getLocalIPs = (callback) => {
pc.createOffer(function(sdp) {
pc.setLocalDescription(sdp);
}, function onerror() {});
}
};

// console.log in the background page
const bglog = (obj) => {
if (chrome && chrome.runtime) {
chrome.runtime.sendMessage({type: "bglog", obj: obj});
}
}
};

// extract domain of url
const extractDomain = (url) => {
Expand All @@ -57,23 +60,86 @@ const extractDomain = (url) => {
}
//find & remove port number
domain = domain.split(':')[0];
return domain;
}
return domain.toLowerCase().replace("www.", "");
};

// read as text
const readResponseAsText = (response) => {
return response.text();
}
};

// read as json
const readResponseAsJSON = (response) => {
return response.json();
}
};

// check if valid response
const validateResponse = (response) => {
if (!response.ok) {
throw Error(response.statusText);
}
return response;
};

const ValidURL = (url) => {
// if parameter is array, then we check all its elements
if (url instanceof Array) {
for (let i = 0; i < url.length; ++ i) {
// recursion call
if (!ValidURL(url[i])) { // arguments.callee - strict mode
return false;
}
}
return true;
}
if (url == null) {
return false;
}
if (url == "") {
return false;
}
if (url.length <= 7) {
return false;
}
function _ValidURL(url) {
return /^(https?:)?\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/{1,2}((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i.test(url);
}
if (_ValidURL(url)) {
return true;
}
if (url.length > 5) {
if (url.startsWith("http:\\/\\/") || url.startsWith("https:\\/\\/")) {
return _ValidURL(url.replace(/\\\//g, "/"));
}
}
return false;
};

function FixURL(url) {
if (url.length > 5) {
if (url.startsWith("http:\\/\\/") || url.startsWith("https:\\/\\/")) {
return url.replace(/\\\//g, "/");
}
}
if (url.length > 5) {
if ((url.charAt(0) == '/') && (url.charAt(1) == '/')) {
return "http:" + url;
}
}
return url;
}

function getParameterByName(name, url) {
name = name.replace(/[\[\]]/g, "\\$&");
let regex = new RegExp("[?&]" + name + "(=([^&#]*)|&|#|$)"),
results = regex.exec(url);
if (!results) return null;
if (!results[2]) return '';
return decodeURIComponent(results[2].replace(/\+/g, " "));
}

if (typeof module !== 'undefined' && typeof module.exports !== 'undefined') {
module.exports = {
getParameterByName, FixURL, extractDomain, ValidURL
};
}
Loading