cloudberrybob / 9tensu open links

// ==UserScript==
// @name         9tensu open links
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @updateURL https://openuserjs.org/meta/cloudberrybob/9tensu_open_links.meta.js
// @downloadURL https://openuserjs.org/install/cloudberrybob/9tensu_open_links.user.js
// @license MIT
// @match        *.9tensu.com/search/label/*
// @grant        none
// ==/UserScript==

var checkExist = setInterval(function() {
    var links = document.evaluate(
        "//a[contains(@class,'item-thumbnail')]",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
if (links.snapshotLength != 0){
    for (var i = 0; i < links.snapshotLength; i++){
		var EditLink = links.snapshotItem(i);
		var theUrl = EditLink.href;
    if (theUrl.includes("http://www.9tensu.com")) {
    window.open(theUrl, '_blank')
        }
	}
      clearInterval(checkExist);
   }
}, 100);



//myRequest();

function myRequest() {



  var links = document.evaluate(
        "//a[contains(@class,'item-thumbnail')]",
		document,
		null,
		XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE,
		null);
if (links.snapshotLength == 0){
    setTimeout(myRequest(), 3000);
    return;
}
console.log(links.snapshotLength);
for (var i = 0; i < links.snapshotLength; i++){
		var EditLink = links.snapshotItem(i);
		var theUrl = EditLink.href;
    if (theUrl.includes("http://www.9tensu.com")) {
    window.open(theUrl, '_blank')
        }
	}
}