Advertisement
MertcanGokgoz

Keyword Generator

Dec 20th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 5 6.00 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4.     <meta charset="UTF-8">
  5.     <title>Keyword Generator</title>
  6.     <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
  7.     <style>
  8.         html, body {
  9.             height: 100%;
  10.         }
  11.  
  12.         html {
  13.             display: table;
  14.             width: 100%;
  15.         }
  16.  
  17.         body {
  18.             display: table-cell;
  19.             text-align: center;
  20.             vertical-align: middle;
  21.         }
  22.     </style>
  23.     <script type="text/javascript">
  24.  
  25.         var hashMapResults = {};
  26.         var numOfKeywords = 0;
  27.         var doWork = false;
  28.         var keywordsToQuery = new Array();
  29.         var keywordsToQueryIndex = 0;
  30.         var queryflag = false;
  31.  
  32.         window.setInterval(DoJob, 750);
  33.  
  34.         function StartJob() {
  35.             if (doWork == false) {
  36.                 hashMapResults = {};
  37.                 numOfKeywords = 0;
  38.                 keywordsToQuery = new Array();
  39.                 keywordsToQueryIndex = 0;
  40.  
  41.                 hashMapResults[""] = 1;
  42.                 hashMapResults[" "] = 1;
  43.                 hashMapResults["  "] = 1;
  44.  
  45.                 var ks = $('#input').val().split("\n");
  46.                 var i = 0;
  47.                 for (i = 0; i < ks.length; i++) {
  48.                    keywordsToQuery[keywordsToQuery.length] = ks[i];
  49.  
  50.                    var j = 0;
  51.                    for (j = 0; j < 26; j++) {
  52.                        var chr = String.fromCharCode(97 + j);
  53.                        var currentx = ks[i] + ' ' + chr;
  54.                        keywordsToQuery[keywordsToQuery.length] = currentx;
  55.                        hashMapResults[currentx] = 1;
  56.                    }
  57.                }
  58.                //document.getElementById("input").value = '';
  59.                document.getElementById("input").value += "\r\n";
  60.  
  61.                doWork = true;
  62.                $('#startjob').val('Stop');
  63.            }
  64.            else {
  65.                doWork = false;
  66.                alert("Stopped");
  67.                $('#startjob').val('Start');
  68.            }
  69.        }
  70.  
  71.        function DoJob() {
  72.            if (doWork == true && queryflag == false) {
  73.                if (keywordsToQueryIndex < keywordsToQuery.length) {
  74.                    var currentKw = keywordsToQuery[keywordsToQueryIndex];
  75.                    QueryKeyword(currentKw);
  76.                    keywordsToQueryIndex++;
  77.                }
  78.                else {
  79.                    if (numOfKeywords != 0) {
  80.                        alert("Finish");
  81.                        doWork = false;
  82.                        $('#startjob').val('Start');
  83.                    }
  84.                    else {
  85.                        keywordsToQueryIndex = 0;
  86.                    }
  87.                }
  88.            }
  89.        }
  90.  
  91.        function QueryKeyword(keyword) {
  92.            var querykeyword = keyword;
  93.            //var querykeyword = encodeURIComponent(keyword);
  94.            var queryresult = '';
  95.            queryflag = true;
  96.  
  97.            $.ajax({
  98.                url: "http://suggestqueries.google.com/complete/search",
  99.                jsonp: "jsonp",
  100.                dataType: "jsonp",
  101.                data: {
  102.                    q: querykeyword,
  103.                    client: "chrome"
  104.                },
  105.                success: function (res) {
  106.                    var retList = res[1];
  107.  
  108.                    var i = 0;
  109.                    var sb = '';
  110.                    for (i = 0; i < retList.length; i++) {
  111.                        var currents = CleanVal(retList[i]);
  112.                        if (hashMapResults[currents] != 1) {
  113.                            hashMapResults[currents] = 1;
  114.                            sb = sb + CleanVal(retList[i]) + '\r\n';
  115.                            numOfKeywords++;
  116.  
  117.                            keywordsToQuery[keywordsToQuery.length] = currents;
  118.  
  119.                            var j = 0;
  120.                            for (j = 0; j < 26; j++) {
  121.                                var chr = String.fromCharCode(97 + j);
  122.                                var currentx = currents + ' ' + chr;
  123.                                keywordsToQuery[keywordsToQuery.length] = currentx;
  124.                                hashMapResults[currentx] = 1;
  125.                            }
  126.                        }
  127.                    }
  128.                    $("#numofkeywords").html(numOfKeywords);
  129.                    document.getElementById("input").value += sb;
  130.                    var textarea = document.getElementById("input");
  131.                    textarea.scrollTop = textarea.scrollHeight;
  132.                    queryflag = false;
  133.                }
  134.            });
  135.        }
  136.  
  137.        function CleanVal(input) {
  138.            var val = input;
  139.            val = val.replace("\\u003cb\\u003e", "");
  140.            val = val.replace("\\u003c\\/b\\u003e", "");
  141.            val = val.replace("\\u003c\\/b\\u003e", "");
  142.            val = val.replace("\\u003cb\\u003e", "");
  143.            val = val.replace("\\u003c\\/b\\u003e", "");
  144.            val = val.replace("\\u003cb\\u003e", "");
  145.            val = val.replace("\\u003cb\\u003e", "");
  146.            val = val.replace("\\u003c\\/b\\u003e", "");
  147.            val = val.replace("\\u0026amp;", "&");
  148.            val = val.replace("\\u003cb\\u003e", "");
  149.            val = val.replace("\\u0026", "");
  150.            val = val.replace("\\u0026#39;", "'");
  151.            val = val.replace("#39;", "'");
  152.            val = val.replace("\\u003c\\/b\\u003e", "");
  153.            val = val.replace("\\u2013", "2013");
  154.            if (val.length > 4 && val.substring(0, 4) == "http") val = "";
  155.             return val;
  156.         }
  157.  
  158.     </script>
  159.     <META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
  160. </head>
  161. <body>
  162. <div id=numofkeywords></div>
  163. <textarea id=input style="width: 600px; height: 300px;"></textarea><br><br>
  164. <input id=startjob onclick="StartJob();" type=button value="Generate!">
  165. <div id=container></div>
  166. <textarea id=queryoutput style="display:none;"></textarea><br>
  167. </body>
  168. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement