DLSite Product Information Injector

Inject the information of a DLSite product to your restaurant.

< Feedback on DLSite Product Information Injector

Question/comment

Deleted user 1006475
§
Posted: 2023-01-03

var fullRegexs = [/(RJ)[0-9]{6}\b|(RJ)[0-9]{8}\b/gi, /(VJ)[0-9]{6}\b|(VJ)[0-9]{8}\b/gi];

var partialRegexs = [/[0-9]{8}|[0-9]{6}/gi];

var languageRegexs = [/(거|퍼)[0-9]{6}\b|(거|퍼)[0-9]{8}\b/gi];

var defaultPrefix = 'RJ';
var default2Prefix = 'VJ';

// Get matched products from text.
function getMatchedProducts(text) {
// Preprocess the inputted text.
text = String(text);
text = text.replace(/https?:\/\/(arca.live\/b\/simya\/)[0-9]*/g, ""); // Ignore arca live post url.

// Get matches from the text with regexs.
var matches = [];

for (let i = 0; i < fullRegexs.length; i++) {
let tempArr = [];
tempArr = text.match(fullRegexs[i]);

if (tempArr == null) {
continue;
}

for (let j = 0; j < tempArr.length; j++) {
if (tempArr[j] != null) {
matches.push(tempArr[j].toUpperCase());
}
}
}

for (let i = 0; i < languageRegexs.length; i++) {
let tempArr = [];
tempArr = text.match(languageRegexs[i]);

if (tempArr == null) {
continue;
}

for (let j = 0; j < tempArr.length; j++) {
if (tempArr[j] != null) {
// If the product code is already exist, ignore current index.
var text_check = tempArr[j].substr(0, 1);
tempArr[j] = tempArr[j].substr(1);

if ("거"==text_check) {
matches.push(defaultPrefix.toUpperCase() + tempArr[j]);
}

if ("퍼"==text_check) {
matches.push(default2Prefix.toUpperCase() + tempArr[j]);
}
}
}
}

for (let i = 0; i < partialRegexs.length; i++) {
let tempArr = [];
tempArr = text.match(partialRegexs[i]);

if (tempArr == null) {
continue;
}

for (let j = 0; j < tempArr.length; j++) {
if (tempArr[j] != null) {
// If the product code is already exist, ignore current index.
if (matches.includes("RJ" + tempArr[j]) || matches.includes("VJ" + tempArr[j])) {
break;
}
if (matches.includes("거" + tempArr[j]) || matches.includes("퍼" + tempArr[j])) {
break;
}

matches.push(defaultPrefix.toUpperCase() + tempArr[j]);
}
}
}

이 코드로 편집하면 6, 8글자 코드와 거와 퍼가 포함된 코드를 검색할 수 있습니다.

Post reply

Sign in to post a reply.