Git Product home page Git Product logo

Comments (6)

AurelionSoldMe avatar AurelionSoldMe commented on July 18, 2024

``{
"guid": "03f193cd-ab75-43f7-a2b7-6c74e133f6ba",
"rule_name": "test",
"url_regex": "?:https://)*(?:www\\.)novelmax\\.net/n/.",
"pagetype_code": " const urlPattern = /^https:\/\/novelmax\.net\/n\/florida-mans-general-store-in-cultivation-world/i;\n\n // Check if the current page is supported by the rule\n if (window.location.href.match(urlPattern)) {\n // Check for captcha pages\n if ($('.captcha-page').length > 0) {\n // Check if it's an Auto-Captcha page\n if ($('.auto-redirect-captcha').length > 0) {\n // Auto-Redirect, no user intervention needed\n return -1;\n } else {\n // Manual-Captcha, user might need to use the renderer\n return -2;\n }\n } else {\n // Page is supported, return 0\n return 0;\n }\n } else {\n // Page not supported by the rule\n return -3;\n }\n}\n",
"toc_code": "let retMe = {\n 'CoverURL': $('img[src="https://novelmax.net/media/novel/florida-mans-general-store-in-cultivation-world.jpg"]').attr('src'),\n 'Title': $('h3.title').text(),\n 'Summary': $('.desc-text').text().replace(/\n/g, '
'),\n 'ChapterCount': 0,\n 'ChapterURLs': [],\n};\n\nawait sleep(100);\n\n// Extract all chapter URLs\nlet chapterURLs = [];\n$(".list-chapter li a").each(function () {\n let chapterUrl = $(this).attr("href");\n chapterURLs.push(chapterUrl);\n});\n\nretMe.ChapterURLs = chapterURLs.reverse();\nretMe.ChapterCount = retMe.ChapterURLs.length;\n\nreturn retMe;",
"chapter_code": "injectJquery();\n\nlet visitedChapterURLs = new Set();\n\nlet retMe;\n\nif (isTOCPage()) {\n throw new Error("Error: Script is on the Table of Contents page. Not a chapter page.");\n} else {\n let currentChapterURL = window.location.href;\n\n if (visitedChapterURLs.has(currentChapterURL)) {\n throw new Error("Error: Same chapter URL loaded twice. Breaking the script.");\n }\n\n visitedChapterURLs.add(currentChapterURL);\n\n // Check if the next chapter button is disabled\n let nextChapterButton = $('#next_chap');\n if (nextChapterButton.length > 0 && nextChapterButton.attr('disabled') !== undefined) {\n throw new Error("Error: Next chapter button is disabled. Breaking the script.");\n }\n\n retMe = [\n {\n "title": $('p:contains("Chapter")').text(),\n "content": $('#chr-content').html(),\n "nextURL": getNextChapterURL()\n },\n ];\n}\n\nfunction isTOCPage() {\n // Add logic to identify if it's the Table of Contents page\n // You can use specific elements or patterns that are unique to TOC\n // For example, if the TOC has an element with class "toc-container"\n return $('.toc-container').length > 0;\n}\n\nfunction getNextChapterURL() {\n // Extract the URL of the next chapter link\n let nextChapterLink = $('#next_chap');\n if (nextChapterLink.length > 0) {\n return nextChapterLink.attr('href');\n } else {\n throw new Error("Error: Last chapter reached. No next chapter found.");\n }\n}\n\nreturn retMe;\n",
"url_blocks": "pubfuture-ad.com"
},

from fanfiction-manager.

AurelionSoldMe avatar AurelionSoldMe commented on July 18, 2024

Added the rule into a txt since github doesnt like the raw paste

rule.txt

from fanfiction-manager.

AurelionSoldMe avatar AurelionSoldMe commented on July 18, 2024

Solved the issues with the regex but still not working correct

(?:https?://)(?:www\.)?novelmax\.net/.

Rule applied -> novelmax
Downloading Novel Metadata...
Error -> [SCRIPT] Script failed to execute, this normally means an error was thrown. Check the renderer console for the error.

from fanfiction-manager.

AurelionSoldMe avatar AurelionSoldMe commented on July 18, 2024

Solved the issue, put the solution below for others

{
"guid": "03f193cd-ab75-43f7-a2b7-6c74e133f6ba",
"rule_name": "novelmax",
"url_regex": "(?:https://)*(?:www\.)novelmax.net/.",
"pagetype_code": "injectJquery();\n\nreturn 0;",
"toc_code": "// Click on the tab to load chapters\n$('a[href="#tab-chapters"]').click();\n\n// Wait for the tab to be fully expanded\nawait new Promise(resolve => {\n let checkInterval = setInterval(() => {\n if ($('#tab-chapters-title[aria-expanded="true"]').length > 0) {\n clearInterval(checkInterval);\n resolve();\n }\n }, 500);\n});\n\n// Navigate to the page containing the "Chapter List" element\nwindow.location.href = $('a[href="#tab-chapters"]').attr("href");\n\n// Wait for the page to load, you can adjust the sleep duration as needed\nawait sleep(2000);\n\n// Extract all chapter URLs\nlet chapterURLs = [];\n$(".list-chapter li a").each(function () {\n let chapterUrl = $(this).attr("href");\n chapterURLs.push(chapterUrl);\n});\n\n// Reverse the array if needed\n//chapterURLs = chapterURLs.reverse();\n\nlet retMe = {\n 'CoverURL': $('img[src="https://novelmax.net/media/novel/florida-mans-general-store-in-cultivation-world.jpg"]').attr('src'),\n 'Title': $('h3.title').text(),\n 'Summary': $('.desc-text').text().replace(/\n/g, '
'),\n 'ChapterCount': chapterURLs.length,\n 'ChapterURLs': chapterURLs,\n};\n\nreturn retMe;\n",
"chapter_code": "injectJquery();\n\nlet visitedChapterURLs = new Set();\n\nlet retMe;\n\nif (isTOCPage()) {\n throw new Error("Error: Script is on the Table of Contents page. Not a chapter page.");\n} else {\n let currentChapterURL = window.location.href;\n\n if (visitedChapterURLs.has(currentChapterURL)) {\n throw new Error("Error: Same chapter URL loaded twice. Breaking the script.");\n }\n\n visitedChapterURLs.add(currentChapterURL);\n\n // Check if the next chapter button is disabled\n let nextChapterButton = $('#next_chap');\n if (nextChapterButton.length > 0 && nextChapterButton.attr('disabled') !== undefined) {\n throw new Error("Error: Next chapter button is disabled. Breaking the script.");\n }\n\n retMe = [\n {\n "title": $('p:contains("Chapter")').text(),\n "content": $('#chr-content').html(),\n "nextURL": getNextChapterURL()\n },\n ];\n}\n\nfunction isTOCPage() {\n // Add logic to identify if it's the Table of Contents page\n // You can use specific elements or patterns that are unique to TOC\n // For example, if the TOC has an element with class "toc-container"\n return $('.toc-container').length > 0;\n}\n\nfunction getNextChapterURL() {\n // Extract the URL of the next chapter link\n let nextChapterLink = $('#next_chap');\n if (nextChapterLink.length > 0) {\n return nextChapterLink.attr('href');\n } else {\n throw new Error("Error: Last chapter reached. No next chapter found.");\n }\n}\n\nreturn retMe;\n",
"url_blocks": "pubfuture-ad.com"
},

from fanfiction-manager.

AurelionSoldMe avatar AurelionSoldMe commented on July 18, 2024

solved put in txt.

Remove the <

at the start and end of it, was a failed copy and paste attempt into github as a quote
rule.txt

from fanfiction-manager.

gmastergreatee avatar gmastergreatee commented on July 18, 2024

Thanks for the rule. Will add to rule-list

Just wanted to mention:

1- The Page Type script runs whenever any URL is loaded, there is no need to put duplicate injectJquery() entries in the following scripts. NOTE : This behavior changes on Tester tab, if the retry feature is used.
2- In Ch-Script, nextURL is an optional field, only to be used if chapter list cannot be determined(for any reason) while getting the TOC data. Other than going for retries, I haven't found any use case for this yet, but still added it on a whim at the time I started developing the app

from fanfiction-manager.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.