title: bookmarklet: click for random specified links from a host domain
body: <p><strong>tl;dr:</strong> A bookmarklet that opens in a new tab: random link (with specified multiple html-classes) from a specified domain and code that works with current logins. Thank you.</p>
  
  <p>short version of butchered code:</p>
  
  <pre><code>    javascript:
      (
          var % 20 site = domain.com
          function() {
              window.location.host == site
              void(window.open(document.links[Math.floor(document.querySelectorAll("a.class1, a.class2"))].href, '_blank'))
          }();
  //beautified with: http://jsbeautifier.org/
  </code></pre>
  
  <p><br>
  <br>
  <br></p>
  
  <hr>
  
  <p><strong>To whom it may concern:</strong>
  I have searched around for a while and even considered switching services but although some come close or are similar to my particular request, none have served to address everything the request entails.</p>
  
  <ol>
  <li><p>Execute the script on a specific domain even when no page from said domain is currently open. If login authentication for attaining the information or data for execution is required, read or work in conjunction with existing session.</p></li>
  <li><p>Fetch from a specific domain host, a random link out of all links on that domain with a certain html-class (or indeed otherwise) using preferably, css-selectors.</p></li>
  <li><p>Open the results in a new tab.</p></li>
  </ol>
  
  <p>From butchering such similarities, the result became something like this:</p>
  
  <pre><code>    //bookmarklet
  javascript:
  //anonymous function+ wrapped code before execution
  (
  // function global variables for quick substitution
    var %20 site = domain.com
  function(){
  //set domain for script execution
  window.location.host == site
  //open new tab for
  void(window.open(document.links
  //random link
  [Math.floor
  //with specific classes (elements found with css selectors)
  (document.querySelectorAll("a.class1, a.class2"))
  ]//end random-query
  .href,'_blank' //end page-open
  )//end link-open
  )//end "void"
  }//end function defintion
  //execute
  ();
  //(tried) checked with: 
  //http://www.javascriptlint.com/online_lint.php
  </code></pre>
  
  <p>Lastly, i have attained at most, basic css knowledge. I apologise if this request has anybody headdesking, palming or otherwise in gtfo mode. It is only too sad there is apparently no tag for <em>"Warning: I DIY-ed this stuff"</em> in StackExchange. However, i still would like answers that go into a bit of depth of explaining why and what each correction and modification is.</p>
  
  <p>Thank you presently, for your time and effort.</p>