Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // By exetico - github.com/exetico
- // Manual Import files-selection
- // Optinal: Comment out the part with JS-confirm, if you like to run through a bit faster!
- $('.modal-header:last').css({
- "position": "sticky",
- "z-index": 1000,
- "top": 0,
- "display": "block",
- "height": "70px",
- "background": "#444",
- "color": "white",
- });
- $('.modal-footer:last').css({
- "position": "sticky",
- "z-index": 1000,
- "bottom": 0,
- "display": "block",
- "height": "70px",
- "background": "#444",
- "color": "white",
- });
- // jQuery.fn.scrollTo = function(elem) {
- // var b = $(elem);
- // this.scrollTop(b.position().top - b.height());
- // };
- var totalAmount = $(".series-title-cell.editable:contains('Click to select movie')").length;
- $(".series-title-cell.editable:contains('Click to select movie')").each(function(index) {
- console.log("Looking at no.: " + index + " of " + totalAmount)
- // $("#modal-region").scrollTo($(this));
- var button = $(this);
- var dirRaw = $(this).parent();
- var dir = dirRaw.contents("td.path-cell").contents("div")[0].outerText;
- var dirReplaced = dir.replace(/\./g, " ");
- $('.modal-header:last').html("Last triggered: " + dirReplaced)
- $(this).click()
- if ($('#modal-region2 .modal-body div.x-movie table').length) {
- console.log("Exists!");
- $('.modal-header h3').html(dirReplaced)
- var input, filter, found, table, tr, td, i, j;
- table = $('#modal-region2 .modal-body div.x-movie table');
- tr = table.contents("tbody").contents("tr");
- var matchingValue = dirReplaced.substring(0, 3).toUpperCase()
- var matchingLongValue = dirReplaced.substring(0, 10)
- if (matchingValue === "THE") {
- matchingValue = dirReplaced.replace(/The/, "").substring(0, 4).toUpperCase()
- matchingLongValue = dirReplaced.replace(/The/, "").substring(0, 10)
- }
- console.log("Looking for the following string: ", matchingValue)
- for (i = 0; i < tr.length; i++) {
- td = tr[i].getElementsByTagName("td");
- for (j = 0; j < td.length; j++) {
- if (td[j].innerHTML.toUpperCase().indexOf(matchingValue) > -1) {
- found = true;
- }
- }
- if (found) {
- tr[i].style.display = "";
- found = false;
- } else {
- tr[i].remove(); //tr[i].style.background = "red";
- }
- }
- tableCheck = $('#modal-region2 .modal-body div.x-movie table').contents("tbody").html().length;
- if (tableCheck) {
- console.log("Looks like we found something")
- var tr = $('#modal-region2 .modal-body div.x-movie table').contents("tbody").contents("tr")
- if (tr.length > 1) {
- console.log("More than one found. Trying with a longer title: ", matchingLongValue);
- // We found more than something... Let's find the best match..
- matches = $('#modal-region2 td:contains("' + matchingLongValue + '")');
- matches5 = $('#modal-region2 td:contains("' + matchingLongValue.trim().substring(0, 5) + '")');
- if (matches.length === 1) {
- console.log("All good, now that we only find one. Selected: ", matches[0].innerText)
- matches.click();
- dirRaw[0].style.background = "LightGreen";
- } else if (matches5.length === 1) {
- console.log("All good, now that we only find one. Selected: ", matches5[0].innerText)
- matches5.click();
- dirRaw[0].style.background = "LightGreen";
- } else {
- console.log("I can't make it better.. Please select one!");
- // CONFIRM START - Uncomment this part, if you like.
- // var r = confirm("I can't find the right one - would you like to pick the correct? WARNING: This will stop the script!");
- // if (r == true) {
- // console.log("Please select one - And start me again :)!")
- // button.html("INFO: Manual task...!")
- // //$('.modal-header:first').append('<button style="float:right;" class="btn btn-default" onclick="">Start script again!</button>')
- // dirRaw[0].style.background = "Aquamarine";
- // return false;
- // } else {
- // console.log("OK! I will now move on, like nothing was happend. Please note that you should look into this title later on.. :-)")
- // $('#modal-region2 button.close').click()
- // button.html("INFO: Multiple...")
- // dirRaw[0].style.background = "LightGoldenRodYellow";
- // }
- // CONFIRM END - If uncommented, remove the next four-lines below!
- console.log("OK! I will now move on, like nothing was happend. Please note that you should look into this title later on.. :-)")
- $('#modal-region2 button.close').click()
- button.html("INFO: Multiple...")
- dirRaw[0].style.background = "LightGoldenRodYellow";
- // IF COMFINRM IS UNCOMMENTED, YOU SHOULD REMOVE THE FOUR LINE ABOVE THIS...
- }
- } else {
- console.log("I only found one - Selecting this one: ", tr[0].innerText)
- tr.click()
- dirRaw[0].style.background = "LightGreen";
- }
- } else {
- console.log("Nah, nothing matching... - Skipping this part")
- $('#modal-region2 button.close').click()
- dirRaw[0].style.background = "LightSalmon";
- button.html("INFO: No match!")
- }
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement