There are 29 previous versions of this script.
// ==UserScript==
// @name onemangahelper
// @namespace http://www.onemanga.com
// @description onemangahelper script by samliew
// Documentation http://userscripts.org/scripts/show/27618
// Last updated: 24 Apr 2009
//
// What this script does:
// This script removes almost everything from the comics view page including ads and the header/footer bar,
// and puts direct links to the page images so you can use an external plugin like FlashGot to download all the images in the chapter.
// An option is also included to display all images in order for easier reading.
//
// @include http://*onemanga.com/*
// @exclude http://*onemanga.com/directory/*
// @exclude http://*onemanga.com/recent/*
// @exclude http://forum.onemanga.com/*
// @exclude http://*onemanga.com/chat/*
// @exclude http://*onemanga.com/supportus/*
// @exclude http://*onemanga.com/shop/*
// @exclude http://*onemanga.com/contactus/*
// ==/UserScript==
//
//
// OPTIONS:
// - To change options, go to any page in onemanga.com
// - Right-click on the GM (greasemonkey) icon at the bottom-right corner of the Firefox statusbar.
// - In the GM menu, under "User Script Commands...", you will see the following options.
// - When you select the option, a prompt will ask you whether you want to enable or disable it. (OK=Enable, Cancel=Disable)
// - The options will take effect the next page you open (or refresh the current page)
//
// CURRENT AVAILABLE OPTIONS:
// 1) Auto Show All
// 2) [Load 5 Chapters] Button
// 3) Change Background Color
//
// - Other options displayed but not listed here are for other scripts that you have installed.
// - See description for options at http://userscripts.org/scripts/show/27618
//___________________________________________________________________________
// ===== Start main script =====
var opt= Array();
var body= document.getElementsByTagName("body")[0];
var head= document.getElementsByTagName("head")[0];
// ===== Useful functions =====
function getElementsByClassName(className, tag, elm){
var testClass= new RegExp("(^|\\s)" + className + "(\\s|$)");
var tag= tag || "*"; var elm= elm || document;
var elements= (tag=="*" && elm.all)? elm.all : elm.getElementsByTagName(tag);
var returnElements= []; var current; var length= elements.length;
for(var i=0; i<length; i++){ current= elements[i];
if(testClass.test(current.className)){
returnElements.push(current);
}}
return returnElements;
}
function $(){
var elements= new Array();
for (var i=0; i<arguments.length; i++){
var element= arguments[i];
if(typeof element=='string') element= document.getElementById(element);
if(arguments.length==1) return element;
elements.push(element);
}
return elements;
}
function stripHTML(text){
var re= /(<([^>]+)>)/gi;
return text.replace(re, "");
}
function documentSrcReplace(find, replace){
var re= new RegExp(find, "gi");
head.innerHTML= (head.innerHTML).replace(re, replace);
body.innerHTML= (body.innerHTML).replace(re, replace);
}
function getDirLength() {
var myloc = window.location.href;
var locarray = myloc.split("/");
return locarray.length;
}
// ===== Get current directory =====
var chapter="";
try{
var myloc= window.location.href;
var locarray= myloc.split("/");
chapter= locarray[locarray.length-3];
locarray.pop(); locarray.pop();
locarray[locarray.length-1]="";
var dir= locarray.join("/");
}catch(e){}
// ===== Remove <script>, <noscript> and buttons =====
try{
elems= document.getElementsByTagName("script");
for(i=elems.length;i>= 0;i--){ try{
elems[i].parentNode.removeChild(elems[i]);
}catch(e){continue;}}
elems= document.getElementsByTagName("noscript");
for(i=elems.length;i>= 0;i--){ try{
elems[i].parentNode.removeChild(elems[i]);
}catch(e){continue;}}
elems= document.getElementsByTagName("input");
for(i=elems.length-1;i>=0;i--){ try{
if(elems[i].type=="button") elems[i].parentNode.removeChild(elems[i]);
}catch(e){continue;}}
}catch(e){}
// ===== Remove Ads =====
try{
elems= getElementsByClassName("banner-chapter");
for(i=0;i<elems.length;i++){ try{
elems[i].parentNode.removeChild(elems[i]);
}catch(e){continue;}}
elems= getElementsByClassName("ad-section");
for(i=0;i<elems.length;i++){ try{
elems[i].parentNode.removeChild(elems[i]);
}catch(e){continue;}}
}catch(e){}
if(getDirLength()==7) { // script works for manga pages only
// ===== Remove header & footer =====
try{
$("header").parentNode.removeChild($("header"));
$("footer").parentNode.removeChild($("footer"));
}catch(e){}
// ===== Remove Other Stuff =====
try{
elems= getElementsByClassName("clear")[0];
elems.parentNode.removeChild(elems);
elem= getElementsByClassName("note")[0];
elem.parentNode.removeChild(elem);
elem= getElementsByClassName("chapter-navigation")[0];
elem.innerHTML= (elem.innerHTML).replace(/Page/,'');
elems= getElementsByClassName("chapter-navigation");
try{elems[elems.length-1].parentNode.removeChild(elems[elems.length-1]);} catch(e){}
}catch(e){}
// ===== Change body style =====
try{
var s= document.createElement('style'); s.type= "text/css"; s.innerHTML= "\
body { background-image:none; cursor:default; font-size:16px; font-family:Arial; }";
opt[3]= GM_getValue('bgColour', true);
window.changeBGColour= function(){
s.innerHTML+="body { background-color:"+(opt[3]?'white':'black')+"; }\
body, p, font, div, span, h1,h2,h3, #page-content { color: "+(opt[3]?'black':'white')+"; }";
}
changeBGColour();
head.appendChild(s);
}catch(e){}
// ===== Strip links from header =====
try{
e= document.getElementsByTagName("h1")[0];
e.innerHTML= stripHTML(e.innerHTML)// + " Chapter "+chapter;
}catch(e){}
// ===== Get image url =====
try{
var imgurl= getElementsByClassName("manga-page")[0].src;
var locarray= imgurl.split("/");
locarray.pop();
var imgdir= locarray.join("/");
getElementsByClassName("one-page")[0].innerHTML="";
getElementsByClassName("one-page")[0].id= "showall";
}catch(e){}
// ===== Hide reading instructions =====
try{
find= "<<<<< This series is read from right to left <<<<<";
replace= "<span id='readinstr' style='display:none'>"+find+"</span>";
var re= new RegExp(find, "gi");
$('content').innerHTML= ($('content').innerHTML).replace(re, replace);
}catch(e){}
// ===== Remove comments and whitespace in code =====
try{
find= "\\<!--.*--\\>"; documentSrcReplace(find, '');
find= " "; documentSrcReplace(find, '');
find= "\\s\\n"; documentSrcReplace(find, '');
// find= "\\n\\s"; documentSrcReplace(find, '');
}catch(e){}
// ===== Create previous/next chapter button =====
var btn_str="", btn_str_e="";
try{
btn_str= "<input type='button' value='<< Prev Chapter' onclick=\"try{window.location=\'"+dir+"\'+document.getElementById('chpt_sel').options[document.getElementById('chpt_sel').options.selectedIndex+1].value;}catch(e){this.disabled=true;this.blur();this.value='First Chapter!';}\" id=\"prevchp\" />";
btn_str+= " <input type='button' value='Next Chapter >>' onclick=\"try{window.focus();window.location=\'"+dir+"\'+document.getElementById('chpt_sel').options[document.getElementById('chpt_sel').options.selectedIndex-1].value;}catch(e){this.disabled=true;this.blur();this.value='Last Chapter!';}\" id=\"nextchp\" />";
btn_str_e= escape(btn_str);
}catch(e){}
// ===== Create load next 5 chapters button =====
var btn_str_next5="", btn_str_next5_e="";
try{
opt[2]= GM_getValue('next5', false);
window.doNext5Button= function(){
if(opt[2]){ try{
btn_str_next5= " <input type='button' value='Load 5 Chapters >>' onclick=\"try{for(i=2;i<=5;i++){window.open(\'"+dir+"\'+document.getElementById('chpt_sel').options[document.getElementById('chpt_sel').options.selectedIndex-i].value);}document.getElementById('nextchp').click();}catch(e){this.disabled=true;this.blur();this.value='Last Chapter!';}\" id=\"next5chp\" />";
btn_str_next5_e= escape(btn_str_next5);
}catch(e){}}
}
doNext5Button();
}catch(e){alert(e);}
// ===== List out pages instead =====
try{
var option= getElementsByClassName("page-select")[0].childNodes;
var string="";
var pagesurl= Array();
for(i=0;i<option.length;i++){
if(option[i].value!=undefined){
string+= "<a style='font-size:16px;' href="+imgdir+"/"+option[i].value+".jpg>"+option[i].value+"</a> ";
pagesurl[i]= imgdir+"/"+option[i].value;
}
}
e= getElementsByClassName("page-select")[0];
p= e.parentNode;
p.removeChild(e);
p.innerHTML= p.innerHTML+" "+btn_str+" <input type='button' id='showAllLink' value='SHOW ALL' onclick='this.blur();showall();document.getElementById(\"imglinks\").style.display=\"none\";this.parentNode.removeChild(this);' /><br><br><div id='imglinks' style='margin-left:15%;margin-right:15%;padding-left:4px;padding-right:4px;border:1px dashed #cccccc;border-collapse:collapse;text-align:left;color:#666666;display:auto;'><p>Images: "+string+"</p></div>";
}catch(e){}
// ===== Disable onemanga keyboard shortcuts =====
try{
e= document.createElement('script');
e.type= "text/javascript";
temp= "document.onkeydown= new function(e){return false;}";
e.innerHTML= temp;
head.appendChild(e);
}catch(e){}
// ===== Focus current chapter in select =====
var fc= false, lc= false;
try{
var e= getElementsByClassName("chapter-select")[0];
e.id= "chpt_sel";
e.style.width= "500px";
for(i=0;i<e.options.length;i++){ if(e.options[i].value.substr(0,chapter.length)==chapter){e.selectedIndex=i;} }
}catch(e){}
// ===== Add showall function =====
try{
e= document.createElement('script');
e.type= "text/javascript";
var temp= "<br><br><br>";var str="";
for(i=0;i<pagesurl.length;i++){ if(pagesurl[i]!=undefined)str+="<img src= \""+pagesurl[i]+".jpg\" /><br> <hr><br>"; }
var temp= "var string='"+str+"'; var btn_str_e2='"+btn_str_e+"'; var btn_str_next5_e2='"+btn_str_next5_e+"'; var run=true; function showall(){if(run){document.getElementById('showall').innerHTML=\"<div align='center' id='all' style='text-align:center; font-size:15px; font-family:Calibri, Arial;'>\"+string+\"<p>\"+unescape(btn_str_e2)+unescape(btn_str_next5_e2)+\"<br><input type='button' onclick='javascript:window.scrollTo(0,0);' value='Back To Top' style='margin-top:5px;' /><br><br></p><p>Project by: <a href='http://www.samliew.com' target='_blank'>Samuel Liew</a> | <a href='http://www.userscripts.org/scripts/show/27618' target='_blank'>Script Comments/Feedback & Updates</a><br><a href='http://www.onemanga.com'>OneManga.com</a></p></div>\";try{document.getElementById('readinstr').style.display='block';}catch(e){}run=false;}} function stoperror(){return true;} window.onerror=stoperror;";
e.innerHTML= temp;
head.appendChild(e);
}catch(e){}
// ===== Show all images on page load =====
try{
opt[1]= GM_getValue('showAll', false);
window.autoShowAll= function(){
if(opt[1]){
try{ $('showAllLink').click(); }catch(e){}
document.getElementsByTagName('img')[0].focus();
}
// Focus showall button if not auto
else { $('showAllLink').focus(); }
}
autoShowAll();
}catch(e){}
} // script works for manga pages only END
// ===== Create GM menu items =====
try{
// Auto Show All
window.autoShowAll_menu= function(){
opt[1]= confirm('Enable \"Auto Show All\"?\n\nOK=Yes, Cancel=No');
GM_setValue('showAll', opt[1]);
//alert('Auto Show All is now: '+(opt[1]?'ENABLED':'DISABLED'));
opt[1]?autoShowAll():void(0);
}
GM_registerMenuCommand('Auto Show All', autoShowAll_menu);
// [Load 5 Chapters] Button
window.doNext5Button_menu= function(){
opt[2]= confirm('Enable \"[Load 5 Chapters] Button\"?\n\nOK=Yes, Cancel=No');
GM_setValue('next5', opt[2]);
//alert('[Load 5 Chapters] button is now: '+(opt[2]?'ENABLED':'DISABLED'));
}
GM_registerMenuCommand('[Load 5 Chapters] Button', doNext5Button_menu);
// Change Background Colour
window.changeBGColour_menu= function(){
opt[3]= confirm('Change Background Colour?\n\nOK=White, Cancel=Black');
GM_setValue('bgColour', opt[3]);
//alert('Background Colour is now: '+(opt[3]?'White':'Black'));
}
GM_registerMenuCommand('Change Background Colour', changeBGColour_menu);
}catch(e){}
// End
