lundi 11 mars 2019

Checkbox select by keyword?

I have to order many files within a website, select them by marking them and send them to their respective folders, the problem is that there are more than 12,000 thousand listings of 30 items each! different formats and things that you should sort by category... manually.

Then I ask for your help to create a script that selects the files by keyword, that is, if a compressed file contains the keyword 'MacOS' because I select it and send it to its respective folder, let's see these images that will help me explain better what I wish:

enter image description here

Our robot friend would go through the whole section where these three elements of examples appear.

(1) I would find the keyword 'Mac.OS' - lowercase or uppercase.

(2) And it would select the matching element.

HTML of this section: (For reasons of quantity of characters I have limited the HTML, complete DEMO in JSFiddle)

<div id="FilesListContainer">



<form action="/action/Files/FilesList" autocomplete="off" id="FileListForm" method="post">    <input name="chomikName" type="hidden" value="chomikuj8ceggd">
    <input name="folderId" type="hidden" value="779">
    <input name="fileListSortType" type="hidden" value="Date">
    <input name="fileListAscending" type="hidden" value="False">
    <input name="gallerySortType" type="hidden" value="Name">
    <input name="galleryAscending" type="hidden" value="False">
    <input name="pageNr" type="hidden" value="1">
    <input name="isGallery" type="hidden" value="False">
</form>
    <div class="borderRadius tab" id="sortTab">

        <ul class="borderRadius tabGradientBg">
            <li class="selected" style="width:130px;">sortuj według:</li>

            <li><form action=""><a href="#" rel="nofollow" title="nazwa">nazwa</a><input name="fileListSortType" type="hidden" value="Name"><input name="fileListAscending" type="hidden" value="False"></form></li>
            <li><form action=""><a href="#" rel="nofollow" title="typ pliku">typ pliku</a><input name="fileListSortType" type="hidden" value="Type"><input name="fileListAscending" type="hidden" value="False"></form></li>
            <li><form action=""><a href="#" rel="nofollow" title="rozmiar">rozmiar</a><input name="fileListSortType" type="hidden" value="Size"><input name="fileListAscending" type="hidden" value="False"></form></li>
            <li><form action=""><a class="selected" href="#" rel="nofollow" title="data dodania">data dodania <img alt="Malejąco" src="//x4.static-chomikuj.pl/res/7c24b1ecca.png"></a><input name="fileListSortType" type="hidden" value="Date"><input name="fileListAscending" type="hidden" value="True"></form></li>
                <li style="width:30px;"><span><input type="checkbox" class="selectAllFiles" value="" name=""></span></li>
        </ul>
    </div>


<div id="listView" style="display: block">



<div class="filerow fileItemContainer">



<div class="fileinfo tab">
    <ul class="borderRadius tabGradientBg">
        <li><span>8,0 MB</span></li>
        <li><span class="date">11 mar 19 5:18</span></li>
            <li><span><input type="checkbox" value="6733949428" name="selectFileItem"></span></li>
    </ul>
</div>


<div class="fileActionsButtons clear visibleButtons  fileIdContainer" rel="6733949428" style="visibility: hidden;">
    <ul>
            <li><a class="showFileRating ratingBtn" href="javascript:;" title="Oceń plik"><span class="star5"></span></a></li>
                <li><a href="/chomikuj8ceggd/fff/Excel.Data.Analysis.For.Dummies.4th.Edition,6733949428.epub" class="downloadAction downloadContext" title="pobierz"><img alt="pobierz" src="//x4.static-chomikuj.pl/res/503435f17e.png" title="pobierz"></a></li>

        <li class="fileCommentsAction"><a href="#" title="komentarze" rel="nofollow"><img alt="komentarze" src="//x4.static-chomikuj.pl/res/d9b637b7b4.png" title="komentarze"></a></li>





            <li class="fileActionsFacebookSend" data-url="http://chomikuj.pl/chomikuj8ceggd/fff/Excel.Data.Analysis.For.Dummies.4th.Edition,6733949428.epub" data-title="Excel.Data.Analysis.For.Dummies.4th.Edition">
                <a href="javascript:;"><img alt="Podziel się na Facebook" src="//x4.static-chomikuj.pl/res/585911b602.gif" title="Podziel się na Facebook"></a>
            </li>

            <li><a class="showFileOptions" href="#" title="opcje" rel="nofollow"><img alt="opcje" src="//x4.static-chomikuj.pl/res/e174c25b70.png" title="opcje"></a></li>

    </ul>
</div>

    <div onmouseover="$('.visibleArrow', this).css('visibility', 'visible')" onmouseout="$('.visibleArrow', this).css('visibility', 'hidden');" class="filename txt">
        <h3>
                <a class="expanderHeader downloadAction downloadContext" href="/chomikuj8ceggd/fff/Excel.Data.Analysis.For.Dummies.4th.Edition,6733949428.epub" title="Excel.Data.Analysis.For.Dummies.4th.Edition">
                    <span class="bold">Excel.Data.Analysis.For.Dummies.4th.Edition</span>.epub
                </a>
            <img alt="pobierz" class="downloadArrow visibleArrow" src="//x4.static-chomikuj.pl/res/99a19ffb28.png" style="visibility: hidden;" title="pobierz">
        </h3>
    </div>

    <div style="clear:left;">



    <div rel="Other" class="expType" style="visibility: hidden">
        <a rel="highslide"></a>
    </div>
            <span class="filedescription" style="display: none">

        </span>
    </div>



    <div class="clear">
    </div>

</div>







<div class="filerow fileItemContainer">



<div class="fileinfo tab">
    <ul class="borderRadius tabGradientBg">
        <li><span>9,1 MB</span></li>
        <li><span class="date">11 mar 19 5:13</span></li>
            <li><span><input type="checkbox" value="6733945278" name="selectFileItem"></span></li>
    </ul>
</div>


<div class="fileActionsButtons clear visibleButtons  fileIdContainer" rel="6733945278" style="visibility: hidden;">
    <ul>
            <li><a class="showFileRating ratingBtn" href="javascript:;" title="Oceń plik"><span class="star5"></span></a></li>
                <li><a href="/chomikuj8ceggd/fff/Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_TNT,6733945278.rar(archive)" class="downloadAction downloadContext" title="pobierz"><img alt="pobierz" src="//x4.static-chomikuj.pl/res/503435f17e.png" title="pobierz"></a></li>

        <li class="fileCommentsAction"><a href="#" title="komentarze" rel="nofollow"><img alt="komentarze" src="//x4.static-chomikuj.pl/res/d9b637b7b4.png" title="komentarze"></a></li>





            <li class="fileActionsFacebookSend" data-url="http://chomikuj.pl/chomikuj8ceggd/fff/Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_TNT,6733945278.rar(archive)" data-title="Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_TNT">
                <a href="javascript:;"><img alt="Podziel się na Facebook" src="//x4.static-chomikuj.pl/res/585911b602.gif" title="Podziel się na Facebook"></a>
            </li>

            <li><a class="showFileOptions" href="#" title="opcje" rel="nofollow"><img alt="opcje" src="//x4.static-chomikuj.pl/res/e174c25b70.png" title="opcje"></a></li>

    </ul>
</div>

    <div onmouseover="$('.visibleArrow', this).css('visibility', 'visible')" onmouseout="$('.visibleArrow', this).css('visibility', 'hidden');" class="filename zip">
        <h3>
                <a class="expanderHeader downloadAction downloadContext" href="/chomikuj8ceggd/fff/Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_TNT,6733945278.rar(archive)" title="Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_TNT">
                    <span class="bold">Ad0b3.Zii.2019-Universal.Patcher.v4.1.7.Mac.OS.X_T<span class="e"> </span>NT</span>.rar
                </a>
            <img alt="pobierz" class="downloadArrow visibleArrow" src="//x4.static-chomikuj.pl/res/99a19ffb28.png" style="visibility: hidden;" title="pobierz">
        </h3>
    </div>

    <div style="clear:left;">



    <div rel="Other" class="expType" style="visibility: hidden">
        <a rel="highslide"></a>
    </div>
            <span class="filedescription" style="display: none">

        </span>
    </div>



    <div class="clear">
    </div>

</div>
<div class="filerow alt fileItemContainer">



<div class="fileinfo tab">
    <ul class="borderRadius tabGradientBg">
        <li><span>1,40 GB</span></li>
        <li><span class="date">11 mar 19 5:13</span></li>
            <li><span><input type="checkbox" value="6733945277" name="selectFileItem"></span></li>
    </ul>
</div>


<div class="fileActionsButtons clear visibleButtons  fileIdContainer" rel="6733945277" style="visibility: hidden;">
    <ul>
            <li><a class="showFileRating ratingBtn" href="javascript:;" title="Oceń plik"><span class="star5"></span></a></li>
                <li><a href="/chomikuj8ceggd/fff/Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X-CracksNow,6733945277.dmg(archive)" class="downloadAction downloadContext" title="pobierz"><img alt="pobierz" src="//x4.static-chomikuj.pl/res/503435f17e.png" title="pobierz"></a></li>

        <li class="fileCommentsAction"><a href="#" title="komentarze" rel="nofollow"><img alt="komentarze" src="//x4.static-chomikuj.pl/res/d9b637b7b4.png" title="komentarze"></a></li>





            <li class="fileActionsFacebookSend" data-url="http://chomikuj.pl/chomikuj8ceggd/fff/Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X-CracksNow,6733945277.dmg(archive)" data-title="Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X-CracksNow">
                <a href="javascript:;"><img alt="Podziel się na Facebook" src="//x4.static-chomikuj.pl/res/585911b602.gif" title="Podziel się na Facebook"></a>
            </li>

            <li><a class="showFileOptions" href="#" title="opcje" rel="nofollow"><img alt="opcje" src="//x4.static-chomikuj.pl/res/e174c25b70.png" title="opcje"></a></li>

    </ul>
</div>

    <div onmouseover="$('.visibleArrow', this).css('visibility', 'visible')" onmouseout="$('.visibleArrow', this).css('visibility', 'hidden');" class="filename iso">
        <h3>
                <a class="expanderHeader downloadAction downloadContext" href="/chomikuj8ceggd/fff/Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X-CracksNow,6733945277.dmg(archive)" title="Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X-CracksNow">
                    <span class="bold">Ad0b3.M3di4.3nc0d3r.CC.2019.v13.0.2-Crack.Mac.OS.X<span class="e"> </span>-CracksNow</span>.dmg
                </a>
            <img alt="pobierz" class="downloadArrow visibleArrow" src="//x4.static-chomikuj.pl/res/99a19ffb28.png" style="visibility: hidden;" title="pobierz">
        </h3>
    </div>

    <div style="clear:left;">



    <div rel="Other" class="expType" style="visibility: hidden">
        <a rel="highslide"></a>
    </div>
            <span class="filedescription" style="display: none">

        </span>
    </div>



    <div class="clear">
    </div>

</div>



    <div class="smallBL" id="selectedFilesActionButtons">
        <ul class="disabled">
            <li class="">
                <a class="button smallButton copyFilesBtn" href="javascript:;">
                    <img alt="Kopiuj" src="//x4.static-chomikuj.pl/res/8638d1a887.png" title="Kopiuj">
                </a>Kopiuj</li>
            <li class="">
                <a class="button smallButton moveFilesBtn" href="javascript:;">
                    <img alt="Przenieś" src="//x4.static-chomikuj.pl/res/72d861f112.png" title="Przenieś"></a>Przenieś</li>
            <li class="">
                <a class="button smallButton deleteFilesBtn" href="javascript:;">
                    <img alt="Usuń" src="//x4.static-chomikuj.pl/res/4c264123ef.png" title="Usuń"></a>Usuń</li>
        </ul>
        <p>Zaznaczone pliki:</p>
        <div class="clear"></div>
    </div>


</div>        </div>

enter image description here (3) I would click on 'Move'

<li class="">
                <a class="button smallButton moveFilesBtn" href="javascript:;">
                    <img alt="Przenieś" src="//x4.static-chomikuj.pl/res/72d861f112.png" title="Przenieś"></a>Przenieś</li>

(4) Wait for this window to appear

<div id="ui-tooltip-filesAction" class="ui-tooltip qtip ui-helper-reset ui-tooltip-default dialogWindow ui-tooltip-pos-c ui-draggable" tracking="false" role="alert" aria-live="polite" aria-atomic="false" aria-describedby="ui-tooltip-filesAction-content" aria-hidden="false" style="width: 261px; z-index: 15002; top: 497.333px; left: 477px; display: block; opacity: 1;"><div class="ui-tooltip-titlebar"><div id="ui-tooltip-filesAction-title" class="ui-tooltip-title" aria-atomic="true">Kopiowanie plików</div><a class="ui-state-default ui-tooltip-close ui-tooltip-icon" title="Zamknij" aria-label="Zamknij" role="button"><span class="ui-icon ui-icon-close">×</span></a></div><div class="ui-tooltip-content" id="ui-tooltip-filesAction-content" aria-atomic="true"><div style="display: block;">
<form action="/action/FileDetails/MoveFilesAction" method="post"><input id="ChomikName" name="ChomikName" type="hidden" value="chomikuj8ceggd"><input id="FolderId" name="FolderId" type="hidden" value="779">        <input type="hidden" name="Files" value="6733945277">
<input id="FolderTo" name="FolderTo" type="hidden" value="0">    <div>
        <p>Jesteś w trybie przenoszenia.Aby przenieść plik do innego folderu  
            wystarczy w drzewie folderów Twojego Chomika kliknąć na docelowy folder.</p>
        <input type="reset" class="greenButtonCSS" value="Anuluj przenoszenie">
    </div>
</form></div></div></div>

(5) And finally click on the corresponding folder

<a href="/chomikuj8ceggd/MAC" rel="481" title="MAC" id="Ta_481"><span class="newfile_s">MAC</span></a>

  • (3) It could be accessed from your class
  • (5) It is easy to access it by your ID
    The method to select or mark checkboxes I am afraid that it has to be similar to the 'click' that is given with the mouse, I say it because selecting with the method .prop (' checked ', true) marks them but does not enable the 'Move' option:

Marked with script⚠️

Marked with script

Manual marked

enter image description here

Maybe a MouseEvent (' click ', is correct here, I do not have the necessary knowledge to ensure it


As I mentioned before, for questions of quantity of characters I put the HTML abbreviated, functional, but abbreviated. Now I leave a link to the full DEMO in JSFiddle

Script

Maybe, just maybe you can place the script inside this code so that you execute it every time you press the' enter 'key If there is a better way then I accept it gladly!

document.onkeyup = function(e){
    document.onkeyup = function(e){
        if(e){
            var key = window.event ? e.keyCode : e.which;
                 }else{
            var key = window.event ? event.keyCode : event.which;
                            }
          if (key == '13') {
            //Code you would like to execute


                           }
                                                                }
                             }


- Final clarifications:
  • It would be for a Tampermonkey script

  • Javascript or JQuery

  • The idea is that when executing the script everything is marked with the chosen keyword and then clicks send that to the folder

  • I'm pretty new to this (it's a bit hard to understand haha)




Aucun commentaire:

Enregistrer un commentaire