Skip to content

Instantly share code, notes, and snippets.

@Dither
Last active November 29, 2017 23:56
Show Gist options
  • Save Dither/26e6583de5733f41fabe68f6944b17ef to your computer and use it in GitHub Desktop.
Save Dither/26e6583de5733f41fabe68f6944b17ef to your computer and use it in GitHub Desktop.
Batoto reader service script for AutoPatchWork mod
// ==UserScript==
// @description Batoto reader service script for AutoPatchWork mod.
// @include http://bato.to/*
// @include https://bato.to/*
// ==/UserScript==
(function(){
var on, off, trigger;
function getURL(id, page) {
return 'https://bato.to/areader?id='+id+'&p='+page
}
function getParams(page) {
if (!page) return null;
var params = [], split = page.substr(page.indexOf('#')+1).split('_');
params[0] = split[0];
params[1] = split[1]||1;
return params;
}
var page_data = [];
function handleNewPageLink(event) {
event.detail.link = getURL(page_data[0], page_data[1]);
}
function handleNewPageLoad(event) {
event.detail.url = event.detail.url.replace(/areader\?id=([^&]+)&p=([^&]+)/gi,'reader#$1_$2');
var node = get_node_x(event.detail.htmlDoc, 'id("comic_page")/ancestor::a');
if (node) { page_data = getParams(node.href); }
else {
off('request');
off('load');
event.preventDefault();
event.stopPropagation();
trigger('terminated', { message: 'Last page reached'});
}
}
document.addEventListener('AutoPatchWork.ready', function() {
trigger = AutoPatchWorked.trigger;
on = AutoPatchWorked.on;
off = AutoPatchWorked.off;
get_node_x = AutoPatchWorked.get_node_x;
setTimeout(function() {
window.addEventListener('hashchange', function (e) {
window.location.reload();
}, false);
var link = get_node_x(document, 'id("comic_page")/ancestor::a');
if (link) {
page_data = getParams(link.href);
on('request', handleNewPageLink);
on('load', handleNewPageLoad);
trigger('siteinfo', {
siteinfo : {
url: '^https?://bato\.to/',
pageElement: 'id("comic_page")/ancestor::a',
nextLink: '//a[img[@title="Next Page"]]'
}
});
} else {
trigger('siteinfo', {
siteinfo : {
url: '^https?://bato\.to/',
pageElement: '//table[@class="ipb_table chapters_list"]//tr',
nextLink: '//a[@title="Older Releases"]'
}
});
}
console.log('[APW] Batoto support script loaded!');
}, 4000);
}, false);
}());
{
"SERVICE":"true",
"url":"^https?://bato\\.to",
"jsPatch":"(function(){ var on, off, trigger; function getURL(id, page) { return 'https://bato.to/areader?id='+id+'&p='+page } function getParams(page) { if (!page) return null; var params = [], split = page.substr(page.indexOf('#')+1).split('_'); params[0] = split[0]; params[1] = split[1]||1; return params; } var page_data = []; function handleNewPageLink(event) { event.detail.link = getURL(page_data[0], page_data[1]); } function handleNewPageLoad(event) { event.detail.url = event.detail.url.replace(/areader\\?id=([^&]+)&p=([^&]+)/gi,'reader#$1_$2'); var node = get_node_x(event.detail.htmlDoc, 'id(\"comic_page\")/ancestor::a'); if (node) { page_data = getParams(node.href); } else { off('request'); off('load'); event.preventDefault(); event.stopPropagation(); trigger('terminated', { message: 'Last page reached'}); } } document.addEventListener('AutoPatchWork.ready', function() { trigger = AutoPatchWorked.trigger; on = AutoPatchWorked.on; off = AutoPatchWorked.off; get_node_x = AutoPatchWorked.get_node_x; setTimeout(function() { window.addEventListener('hashchange', function (e) { window.location.reload(); }, false); var link = get_node_x(document, 'id(\"comic_page\")/ancestor::a'); if (link) { page_data = getParams(link.href); on('request', handleNewPageLink); on('load', handleNewPageLoad); trigger('siteinfo', { siteinfo : { url: '^https?://bato\\.to/', pageElement: 'id(\"comic_page\")/ancestor::a', nextLink: '//a[img[@title=\"Next Page\"]]' } }); } else { trigger('siteinfo', { siteinfo : { url: '^https?://bato\\.to/', pageElement: '//table[@class=\"ipb_table chapters_list\"]//tr', nextLink: '//a[@title=\"Older Releases\"]' } }); } console.log('[APW] Batoto support script loaded!');}, 4000); }, false); }());"
},
@namespace url(http://www.w3.org/1999/xhtml);
@-moz-document domain("bato.to") {
#comic_wrap div {
margin-bottom: auto!important;
right: auto!important;
top: auto!important;
}
#vnc_filter_popup_close, body#ipboard_body fieldset.submit, body#ipboard_body p.submit, .ipsForm_submit, ul.post_controls,.signature, .ipbfs_titlebox, #search_options, .topic_buttons li.disabled a, .topic_buttons li.disabled span, .ipsLikeBar_info, p.citation {
background-color: #444444!important;
border-color:#555!important;
color: #CCCCCC!important;
text-shadow: none!important;
}
[style*="border-top-color: rgb(87, 0, 0); border-left-color: rgb(87, 0, 0);"],[style*="border:#C00"] {
background-color: #331515!important;
border-color: #570000!important;
}
.ipsBox_container, .header th, .bar, .ipsSideBlock h3, .general_box h3, .statistics_head, blockquote.ipsBlockquote {
border-color:#444!important;
}
.ipsType_pagetitle, .ipsType_subtitle, blockquote.ipsBlockquote, .ipsBox, #search_wrap,input ,.row1, .post_block.row1, .border, .statistics, .post_block, .ipsComment, .popupInner, .no_messages, .general_box, .ipsSideBlock, .poll_question ol, .ipsBox_container, .ipsFloatingAction, .column_view .post_body, #mainContent {
background: transparent!important;
color:#aaa!important;
}
.cpe #primary_nav, .cpe .maintitle, .cpe #community_app_menu > li.active > a, .cpe .col_c_icon img[src*="f_"], .cpe .f_icon, .cpe .topic_buttons li a, .cpe .pagination .pages li.active, .cpe #primary_extra_menucontent, .cpe #more_apps_menucontent, .cpe .post_block h3, .cpe .mini_pagination a, .cpe .user_controls li a, .cpe #vnc_filter_popup_close, .cpe #search .submit_input, .cpe .col_f_icon img, .cpe .ipsBadge_green, body.cpe #logo, .cpe #themeToggle, .cpe #primary_extra_menucontent, .cpe #more_apps_menucontent, .cpe .submenu_container {
background: rgba(89, 182, 222, 0.3) !important;
}
abbr, acronym , .input_text, .ipsTagBox_wrapper, textarea, select {
background: #444!important;
color:#aaa!important;
border-color: #222!important;
}
a, body {
color: #bbb!important;
}
.pagination .page a, .pagination .back a, .pagination .forward a, .header {
background: #444!important;
color: #ddd!important;
}
.bar, .ipsSideBlock h3, .general_box h3, .statistics_head {
background: #555!important;
}
#recentajaxcontent li, #idm_categories a, #idm_categories li.with_sub.open li, #index_stats .status_list li, #panel_files .file_listing li, #panel_screenshots #ss_linked li, .file_listing, #cart_totals td, div#member_filters li, #files li, .ipsType_sectiontitle, #order_review td, #package_details .package_info, .block_list li, .package_view_top, .member_entry, #help_topics li, .ipsBox_container .ipsType_pagetitle, .userpopup dl, #announcements td, .sideVerticalList li, fieldset.with_subhead ul, .ipsList_data li, .ipsList_withminiphoto li, .ipsList_withmediumphoto li, table.ipb_table td, .store_categories li, #mini_cart li, #index_stats div[id*="statusReply"], #ipg_category .ipg_category_row, .block_inner .ipb_table td, .gallery_pane h2, .status_feedback li[id*="statusReply"], .ipsSideMenu ul li, #usercp_content .ipsType_subtitle, .ipbfs_login_row, .articles .block-1, .articles .type-1x2x2 .article_row, #idm_category .idm_category_row, #category_list li a, .ipsComment, #forum_table.ipb_table tr:last-of-type td {
border-bottom: 1px solid #444!important;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment