mirror of
https://github.com/NohamR/BetterYGG.git
synced 2026-01-10 16:38:21 +00:00
[1.2.8] new domain name and stuff
This commit is contained in:
@@ -10,18 +10,18 @@ var path = window.location.pathname;
|
|||||||
var tableLines = document.querySelectorAll('table.infos-torrent tbody tr');
|
var tableLines = document.querySelectorAll('table.infos-torrent tbody tr');
|
||||||
var downloadLine = tableLines[0];
|
var downloadLine = tableLines[0];
|
||||||
var torrentInfo = downloadLine.cloneNode(true);
|
var torrentInfo = downloadLine.cloneNode(true);
|
||||||
torrentInfo.style = "display: none";
|
torrentInfo.style.display = 'none';
|
||||||
downloadLine.insertAdjacentElement('afterend', torrentInfo);
|
downloadLine.insertAdjacentElement('afterend', torrentInfo);
|
||||||
|
|
||||||
/* Add third party download button */
|
/* Add third party download button */
|
||||||
var downloadButton = downloadLine.querySelector('a.butt');
|
var downloadButton = downloadLine.querySelector('a.butt');
|
||||||
var flexButton = document.createElement('a');
|
var flexButton = document.createElement('a');
|
||||||
flexButton.appendChild(document.createTextNode("Télécharger via discord "));
|
flexButton.appendChild(document.createTextNode('Télécharger via discord '));
|
||||||
var span = document.createElement('span');
|
var span = document.createElement('span');
|
||||||
span.className = "ico_download";
|
span.classList.add('ico_download');
|
||||||
flexButton.appendChild(span);
|
flexButton.appendChild(span);
|
||||||
flexButton.className = "butt discord";
|
flexButton.classList.add('butt', 'discord');
|
||||||
flexButton.style = "display: none";
|
flexButton.style.display = 'none';
|
||||||
flexButton.addEventListener('click', addToDiscord);
|
flexButton.addEventListener('click', addToDiscord);
|
||||||
downloadButton.parentElement.appendChild(flexButton);
|
downloadButton.parentElement.appendChild(flexButton);
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ var torrentId = (/.*\/torrent\/.*\/.*\/(\d+)-/g).exec(window.location.pathname);
|
|||||||
if (torrentId) {
|
if (torrentId) {
|
||||||
torrentId = torrentId[1];
|
torrentId = torrentId[1];
|
||||||
}
|
}
|
||||||
var torrentTitle = document.querySelector('div#title h1').textContent.trim().split(".").join(" ");
|
var torrentTitle = document.querySelector('div#title h1').textContent.trim().split('.').join(' ');
|
||||||
var torrentYear = (/(19\d{2}|2\d{3})/g).exec(torrentTitle);
|
var torrentYear = (/(19\d{2}|2\d{3})/g).exec(torrentTitle);
|
||||||
if (torrentYear) {
|
if (torrentYear) {
|
||||||
torrentYear = torrentYear[1];
|
torrentYear = torrentYear[1];
|
||||||
@@ -48,10 +48,10 @@ if (torrentTitle.includes('1080')) {
|
|||||||
var discordWebhookUrl, discordUserName, categories;
|
var discordWebhookUrl, discordUserName, categories;
|
||||||
chrome.storage.sync.get(['yggToken', 'discordWebhookUrl', 'discordUserName', 'displayDiscord', 'displayAddCategories', 'categories', 'defaultCategories'], function (value) {
|
chrome.storage.sync.get(['yggToken', 'discordWebhookUrl', 'discordUserName', 'displayDiscord', 'displayAddCategories', 'categories', 'defaultCategories'], function (value) {
|
||||||
if (value.yggToken) {
|
if (value.yggToken) {
|
||||||
downloadButton.setAttribute('href', "https://" + window.location.host + "/rss/download?id=" + torrentId + "&passkey=" + value.yggToken);
|
downloadButton.setAttribute('href', `https://${window.location.host}/rss/download?id=${torrentId}&passkey=${value.yggToken}`);
|
||||||
} else {
|
} else {
|
||||||
var alertYggToken = '<div id="error_ygg_button_alert" class="alert alert-danger" role="alert" style="margin-bottom:0;">Une erreur est survenue, Vérifiez que votre token Ygg soit chargé !</div>';
|
var alertYggToken = '<div id="error_ygg_button_alert" class="alert alert-danger" role="alert" style="margin-bottom:0;">Une erreur est survenue, Vérifiez que votre token Ygg soit chargé !</div>';
|
||||||
if (document.readyState !== "complete") {
|
if (document.readyState !== 'complete') {
|
||||||
document.addEventListener('readystatechange', function () {
|
document.addEventListener('readystatechange', function () {
|
||||||
downloadLine.childNodes[3].innerHTML = alertYggToken;
|
downloadLine.childNodes[3].innerHTML = alertYggToken;
|
||||||
}, false);
|
}, false);
|
||||||
@@ -115,13 +115,13 @@ chrome.storage.sync.get(['yggToken', 'discordWebhookUrl', 'discordUserName', 'di
|
|||||||
|
|
||||||
/* Creation of form */
|
/* Creation of form */
|
||||||
var formNode = document.createElement('form');
|
var formNode = document.createElement('form');
|
||||||
formNode.name = "form_info";
|
formNode.name = 'form_info';
|
||||||
formNode.className = "form-horizontal";
|
formNode.classList.add('form-horizontal');
|
||||||
right.appendChild(formNode);
|
right.appendChild(formNode);
|
||||||
|
|
||||||
var row = document.createElement('div');
|
var row = document.createElement('div');
|
||||||
row.className = "row";
|
row.classList.add('row');
|
||||||
row.appendChild(getInputCol("Titre", "title", ["error"], "text", torrentTitle,
|
row.appendChild(getInputCol("Titre", 'title', ['error'], 'text', torrentTitle,
|
||||||
{
|
{
|
||||||
onInput: function () {
|
onInput: function () {
|
||||||
this.classList.remove('error');
|
this.classList.remove('error');
|
||||||
@@ -131,8 +131,8 @@ chrome.storage.sync.get(['yggToken', 'discordWebhookUrl', 'discordUserName', 'di
|
|||||||
formNode.appendChild(row);
|
formNode.appendChild(row);
|
||||||
|
|
||||||
formNode.appendChild(getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, torrentYear, torrentQuality, categories));
|
formNode.appendChild(getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, torrentYear, torrentQuality, categories));
|
||||||
torrentInfo.style.display = "";
|
torrentInfo.style.display = '';
|
||||||
flexButton.style.display = "";
|
flexButton.style.display = '';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -142,13 +142,13 @@ chrome.storage.sync.get(['yggToken', 'discordWebhookUrl', 'discordUserName', 'di
|
|||||||
|
|
||||||
function alert(id) {
|
function alert(id) {
|
||||||
document.querySelectorAll('.alert').forEach(function (elem) {
|
document.querySelectorAll('.alert').forEach(function (elem) {
|
||||||
elem.style.display = "none";
|
elem.style.display = 'none';
|
||||||
});
|
});
|
||||||
document.getElementById(id).style.display = "block";
|
document.getElementById(id).style.display = 'block';
|
||||||
}
|
}
|
||||||
|
|
||||||
function showAlert(id) {
|
function showAlert(id) {
|
||||||
if (document.readyState !== "complete") {
|
if (document.readyState !== 'complete') {
|
||||||
document.addEventListener('readystatechange', function () {
|
document.addEventListener('readystatechange', function () {
|
||||||
alert(id);
|
alert(id);
|
||||||
}, false);
|
}, false);
|
||||||
@@ -171,7 +171,7 @@ function addToDiscord() {
|
|||||||
if (!input) {
|
if (!input) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (input.className.includes('error')) {
|
if (input.classList.contains('error')) {
|
||||||
showAlert('error_form_alert');
|
showAlert('error_form_alert');
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -203,8 +203,8 @@ function addToDiscord() {
|
|||||||
function getInput(name, classes, type, value, attrs = {}) {
|
function getInput(name, classes, type, value, attrs = {}) {
|
||||||
var inputNode = document.createElement('input');
|
var inputNode = document.createElement('input');
|
||||||
inputNode.name = name;
|
inputNode.name = name;
|
||||||
inputNode.className = "form-control " + classes.join(" ");
|
inputNode.classList.add('form-control', ...classes);
|
||||||
inputNode.setAttribute("type", type);
|
inputNode.setAttribute('type', type);
|
||||||
for (var key in attrs) {
|
for (var key in attrs) {
|
||||||
inputNode.setAttribute(key, attrs[key]);
|
inputNode.setAttribute(key, attrs[key]);
|
||||||
}
|
}
|
||||||
@@ -215,17 +215,17 @@ function getInput(name, classes, type, value, attrs = {}) {
|
|||||||
function getSelect(name, classes, options, selected, attrs = {}) {
|
function getSelect(name, classes, options, selected, attrs = {}) {
|
||||||
var selectNode = document.createElement('select');
|
var selectNode = document.createElement('select');
|
||||||
selectNode.name = name;
|
selectNode.name = name;
|
||||||
selectNode.className = "form-control " + classes.join(" ");
|
selectNode.classList.add('form-control', ...classes);
|
||||||
for (var key in attrs) {
|
for (var key in attrs) {
|
||||||
selectNode.setAttribute(key, attrs[key]);
|
selectNode.setAttribute(key, attrs[key]);
|
||||||
}
|
}
|
||||||
for (var index in options) {
|
for (var index in options) {
|
||||||
var type = options[index];
|
var type = options[index];
|
||||||
var option = document.createElement("option");
|
var option = document.createElement('option');
|
||||||
option.value = type;
|
option.value = type;
|
||||||
option.text = type;
|
option.text = type;
|
||||||
if (type === selected) {
|
if (type === selected) {
|
||||||
option.setAttribute("selected", "selected");
|
option.setAttribute('selected', 'selected');
|
||||||
}
|
}
|
||||||
selectNode.appendChild(option);
|
selectNode.appendChild(option);
|
||||||
}
|
}
|
||||||
@@ -234,12 +234,12 @@ function getSelect(name, classes, options, selected, attrs = {}) {
|
|||||||
|
|
||||||
function getFormGroup(input, label, name, size) {
|
function getFormGroup(input, label, name, size) {
|
||||||
var labelNode = document.createElement('label');
|
var labelNode = document.createElement('label');
|
||||||
labelNode.className = "control-label";
|
labelNode.classList.add('control-label');
|
||||||
labelNode.setAttribute("for", name);
|
labelNode.setAttribute('for', name);
|
||||||
labelNode.appendChild(document.createTextNode(label));
|
labelNode.appendChild(document.createTextNode(label));
|
||||||
|
|
||||||
var div = document.createElement('div');
|
var div = document.createElement('div');
|
||||||
div.className = "form-group col-" + size;
|
div.classList.add('form-group', `col-${size}`);
|
||||||
div.appendChild(labelNode);
|
div.appendChild(labelNode);
|
||||||
div.appendChild(input);
|
div.appendChild(input);
|
||||||
return div;
|
return div;
|
||||||
@@ -248,7 +248,7 @@ function getFormGroup(input, label, name, size) {
|
|||||||
function getInputCol(label, name, classes, type, value, {size = 12, attrs = {}, onInput = false}) {
|
function getInputCol(label, name, classes, type, value, {size = 12, attrs = {}, onInput = false}) {
|
||||||
var input = getInput(name, classes, type, value, attrs);
|
var input = getInput(name, classes, type, value, attrs);
|
||||||
if (onInput) {
|
if (onInput) {
|
||||||
input.addEventListener("input", onInput);
|
input.addEventListener('input', onInput);
|
||||||
}
|
}
|
||||||
return getFormGroup(input, label, name, size);
|
return getFormGroup(input, label, name, size);
|
||||||
}
|
}
|
||||||
@@ -256,7 +256,7 @@ function getInputCol(label, name, classes, type, value, {size = 12, attrs = {},
|
|||||||
function getSelectCol(label, name, classes, options, selected, {size = 12, attrs = {}, onInput = false}) {
|
function getSelectCol(label, name, classes, options, selected, {size = 12, attrs = {}, onInput = false}) {
|
||||||
var select = getSelect(name, classes, options, selected, attrs);
|
var select = getSelect(name, classes, options, selected, attrs);
|
||||||
if (onInput) {
|
if (onInput) {
|
||||||
select.addEventListener("input", onInput);
|
select.addEventListener('input', onInput);
|
||||||
}
|
}
|
||||||
return getFormGroup(select, label, name, size);
|
return getFormGroup(select, label, name, size);
|
||||||
}
|
}
|
||||||
@@ -266,22 +266,34 @@ function getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, tor
|
|||||||
var classes = [];
|
var classes = [];
|
||||||
var onInput = false;
|
var onInput = false;
|
||||||
var row = document.createElement('div');
|
var row = document.createElement('div');
|
||||||
row.className = "row";
|
row.classList.add('row');
|
||||||
if (torrentType.season) {
|
if (torrentType.season) {
|
||||||
size = 2;
|
size = 2;
|
||||||
if (torrentSeason === '') {
|
if (torrentSeason === '') {
|
||||||
|
if (torrentEpisode !== '') {
|
||||||
classes = ['error'];
|
classes = ['error'];
|
||||||
|
} else {
|
||||||
|
classes = ['warning'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
onInput = function () {
|
onInput = function () {
|
||||||
torrentSeason = formatEpisodeSeason(this.value);
|
const torrentSeason = formatEpisodeSeason(this.value);
|
||||||
|
const torrentEpisode = formatEpisodeSeason(document.querySelector('form[name="form_info"] input[name="episode"]').value);
|
||||||
this.value = torrentSeason;
|
this.value = torrentSeason;
|
||||||
if (torrentSeason === "") {
|
if (torrentSeason === '') {
|
||||||
this.className += ' error';
|
if (torrentEpisode !== '') {
|
||||||
|
this.classList.add('error');
|
||||||
|
this.classList.remove('warning');
|
||||||
} else {
|
} else {
|
||||||
|
this.classList.add('warning');
|
||||||
|
this.classList.remove('error');
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.classList.remove('warning');
|
||||||
this.classList.remove('error');
|
this.classList.remove('error');
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
row.appendChild(getInputCol("Saison", "season", classes, "number", torrentSeason, {size: size, attrs: {"min": "0"}, onInput: onInput}));
|
row.appendChild(getInputCol("Saison", 'season', classes, 'number', torrentSeason, {size: size, attrs: {'min': '0'}, onInput: onInput}));
|
||||||
classes = [];
|
classes = [];
|
||||||
onInput = false;
|
onInput = false;
|
||||||
|
|
||||||
@@ -289,26 +301,30 @@ function getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, tor
|
|||||||
classes = ['warning'];
|
classes = ['warning'];
|
||||||
}
|
}
|
||||||
onInput = function () {
|
onInput = function () {
|
||||||
torrentEpisode = formatEpisodeSeason(this.value);
|
const torrentEpisode = formatEpisodeSeason(this.value);
|
||||||
this.value = torrentEpisode;
|
this.value = torrentEpisode;
|
||||||
if (torrentEpisode === "") {
|
if (torrentEpisode === '') {
|
||||||
this.className += ' warning';
|
this.classList.add('warning');
|
||||||
} else {
|
} else {
|
||||||
this.classList.remove('warning');
|
this.classList.remove('warning');
|
||||||
}
|
}
|
||||||
|
document.querySelector('form[name="form_info"] input[name="season"]').dispatchEvent(new Event('input', {
|
||||||
|
bubbles: true,
|
||||||
|
cancelable: true,
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
row.appendChild(getInputCol("Episode", "episode", classes, "number", torrentEpisode, {size: size, attrs: {"min": "0"}, onInput: onInput}));
|
row.appendChild(getInputCol("Episode", 'episode', classes, 'number', torrentEpisode, {size: size, attrs: {'min': '0'}, onInput: onInput}));
|
||||||
classes = [];
|
classes = [];
|
||||||
onInput = false;
|
onInput = false;
|
||||||
|
|
||||||
var space = document.createElement('div');
|
var space = document.createElement('div');
|
||||||
space.className = 'col-1';
|
space.classList.add('col-1');
|
||||||
row.appendChild(space);
|
row.appendChild(space);
|
||||||
row.appendChild(getInputCol("ID", "id", [], "text", torrentId, {size: size}));
|
row.appendChild(getInputCol("ID", 'id', [], 'text', torrentId, {size: size}));
|
||||||
row.appendChild(space.cloneNode());
|
row.appendChild(space.cloneNode());
|
||||||
} else {
|
} else {
|
||||||
row.appendChild(getInputCol("ID", "id", [], "text", torrentId, {size: size}));
|
row.appendChild(getInputCol("ID", 'id', [], 'text', torrentId, {size: size}));
|
||||||
row.appendChild(getInputCol("Year", "year", ['warning'], "text", torrentYear, {size: size,
|
row.appendChild(getInputCol("Year", 'year', ['warning'], 'text', torrentYear, {size: size,
|
||||||
onInput: function () {
|
onInput: function () {
|
||||||
if (this.value.length !== 4) {
|
if (this.value.length !== 4) {
|
||||||
this.classList.remove('warning');
|
this.classList.remove('warning');
|
||||||
@@ -322,12 +338,12 @@ function getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, tor
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
row.appendChild(getInputCol("Quality", "quality", [], "text", torrentQuality, {size: size}));
|
row.appendChild(getInputCol("Quality", 'quality', [], 'text', torrentQuality, {size: size}));
|
||||||
|
|
||||||
onInput = function () {
|
onInput = function () {
|
||||||
torrentType = getTypeFromName(categories, this.options[this.selectedIndex].value);
|
const torrentType = getTypeFromName(categories, this.options[this.selectedIndex].value);
|
||||||
if (torrentType.name === 'unknown') {
|
if (torrentType.name === 'unknown') {
|
||||||
this.className += ' error';
|
this.classList.add('error');
|
||||||
} else {
|
} else {
|
||||||
this.classList.remove('error');
|
this.classList.remove('error');
|
||||||
row.replaceWith(getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, torrentYear, torrentQuality, categories));
|
row.replaceWith(getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, torrentYear, torrentQuality, categories));
|
||||||
@@ -353,12 +369,12 @@ function getSecondRow(torrentType, torrentSeason, torrentEpisode, torrentId, tor
|
|||||||
/* Ensure the episode and season number is nice */
|
/* Ensure the episode and season number is nice */
|
||||||
function formatEpisodeSeason(value) {
|
function formatEpisodeSeason(value) {
|
||||||
if (value > 0 && value <= 9) {
|
if (value > 0 && value <= 9) {
|
||||||
if (value.includes("0")) {
|
if (value.includes('0')) {
|
||||||
value = "" + parseInt(value);
|
value = `${parseInt(value)}`;
|
||||||
}
|
}
|
||||||
value = "0" + value;
|
value = `0${value}`;
|
||||||
} else {
|
} else {
|
||||||
while (value.substring(0, 1) === "0") {
|
while (value.substring(0, 1) === '0') {
|
||||||
value = value.substring(1, value.length);
|
value = value.substring(1, value.length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -375,9 +391,9 @@ function getTypeFromUrl(categories) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: "unknown",
|
name: 'unknown',
|
||||||
season: false,
|
season: false,
|
||||||
urls: ["/"]
|
urls: ['/']
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,8 +404,8 @@ function getTypeFromName(categories, name) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
name: "unknown",
|
name: 'unknown',
|
||||||
season: false,
|
season: false,
|
||||||
urls: ["/"]
|
urls: ['/']
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "BetterYGG",
|
"name": "BetterYGG",
|
||||||
"version": "1.2.7",
|
"version": "1.2.8",
|
||||||
"description": "Téléchargez des torrents sur YGG sans ètre connecté et autres !!!",
|
"description": "Téléchargez des torrents sur YGG sans ètre connecté et autres !!!",
|
||||||
"icons": {
|
"icons": {
|
||||||
"16": "img/flexgg16.png",
|
"16": "img/flexgg16.png",
|
||||||
@@ -28,22 +28,22 @@
|
|||||||
],
|
],
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*.yggtorrent.li/torrent/*"],
|
"matches": ["https://*.yggtorrent.nz/torrent/*"],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"js": ["js/utilsFunctions.js", "contentScripts/addTorrent/addTorrent.js"]
|
"js": ["js/utilsFunctions.js", "contentScripts/addTorrent/addTorrent.js"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": ["https://*.yggtorrent.li/"],
|
"matches": ["https://*.yggtorrent.nz/"],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"js": [ "contentScripts/homePage.js"]
|
"js": [ "contentScripts/homePage.js"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": ["https://*.yggtorrent.li/*"],
|
"matches": ["https://*.yggtorrent.nz/*"],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"js": ["js/utilsFunctions.js", "contentScripts/allPages/allPages.js"]
|
"js": ["js/utilsFunctions.js", "contentScripts/allPages/allPages.js"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"matches": ["https://*.yggtorrent.li/engine/search*"],
|
"matches": ["https://*.yggtorrent.nz/engine/search*"],
|
||||||
"run_at": "document_idle",
|
"run_at": "document_idle",
|
||||||
"js": ["js/utilsFunctions.js", "contentScripts/search/search.js"]
|
"js": ["js/utilsFunctions.js", "contentScripts/search/search.js"]
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user