Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Bookmarklet:
- javascript:(function(){with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=e3J0FyiP')._})();
- This is a collection of a bunch of javascript codes for idlegamemaker. Untested.
- Currently includes:
- Multibuy (modified to have buy all instead of buy 10 and sell 100 added)
- Import/export
- Short numbers (modified to make it easy to edit and goes to infinity)
- Autoclick (original, lets you autoclick one clickable at 20/s)
- to see the code of one, control F "===--name--===". (without the quotes)
- if someone can help me with how to make a box where you can enter your own number, it would be great. (I know how to use the built-in JS popup function I forget the name of, but that's inconvenient.)
- ===--MULTIBUY--===*/
- (function()
- {
- if(l('saveBox').innerHTML.indexOf('<select name="multibuy">') == -1)
- {
- var somethingidk = '<select name="multibuy">';
- for(i in Game.buildings)
- {
- if(Game.buildings[i].visible && Game.buildings[i].real)
- {
- somethingidk+= "<option value=" + Game.buildings[i].key + '>' + Game.buildings[i].name + '</option>';
- }
- }
- somethingidk+= '</select>';
- return l('saveBox').innerHTML += somethingidk + "<div class='button' onclick='buyall();'>Buy All</div>" + "<div class='button' onclick='buylots(100);'>Buy 100</div>" + "<div class='button' onclick='sellall();'>Sell all</div>" + "<div class='button' onclick='sell100();'>Sell 100</div>";
- }
- }())
- sellall = function()
- {
- var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
- if(Game.cssData.indexOf(".sell") == -1 && Game.cssData.indexOf("#sell-" + Game.buildings[build].key) == -1)
- {
- if(confirm('Are you sure you want to sell all ' + Game.buildings[build].plural + '?'))
- {
- while(Game.buildings[build].amount > 0 && Game.buildings[build].visible)
- {
- Game.buildings[build].Sell();
- }}}}
- sell100 = function(){
- var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
- for(i=0;i<100;i++){
- if(Game.cssData.indexOf(".sell") == -1 && Game.cssData.indexOf("#sell-" + Game.buildings[build].key) == -1){
- if(confirm('Are you sure you want to sell 100 ' + Game.buildings[build].plural + '?')){
- if(Game.buildings[build].amount > 0 && Game.buildings[build].visible){
- Game.buildings[build].Sell();
- }}}}}
- buyall = function(){
- var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
- while(Game.buildings[build].visible && Game.buildings[build].CanBuy()){
- Game.buildings[build].Buy();
- }}
- buylots = function(amount)
- {
- var build = document.getElementsByName('multibuy')[0].selectedOptions[0].value;
- for(i=0;i<amount;i++)
- {
- if(Game.buildings[build].visible && Game.buildings[build].CanBuy())
- {
- Game.buildings[build].Buy();
- }}}
- with(l('saveBox')){
- if(innerHTML.indexOf("confirm('Are you sure you want to reset?')") == -1) innerHTML = innerHTML.replace("Game.Reset()","if(confirm('Are you sure you want to reset?')){Game.Reset()}")}
- document.getElementsByName('multibuy')[0].onfocus=function(){
- multbuyopt = '';
- for(i in Game.buildings)
- {
- if(Game.buildings[i].visible && Game.buildings[i].real)
- {
- multbuyopt+= "<option value=" + Game.buildings[i].key + '>' + Game.buildings[i].name + '</option>';
- }}
- document.getElementsByName('multibuy')[0].innerHTML = multbuyopt;}
- /*===--IMPORT/EXPORT--===*/
- (function(){with(document)(head.appendChild(createElement('script')).src='http://pastebin.com/raw.php?i=C1kJemmr')._})();
- /* not even gonna bother editing this one yet. Might change it a bit in the future though.
- ===--SHORT NUMBERS--===*/
- nums = ['k','M','B','T',' Qa',' Qi',' Sx',' Sp',' Oc',' Nn'];
- nums2= ['',' U',' D',' T',' Qa',' Qi',' Sx',' Sp',' Oc',' Nn'];
- nums3= ['Dc','Vg','Tg','Qag','Qig','Sxg','Spg','Ocg','Nng','Cc'];
- //if you want to modify this, note that nums is only for up to a decillion-0.001. nums2 gets used after that with nums3 placed after it. nums2 will reset after it gets to it's 10th entry instead increasing nums3.
- function Beautify(num,floats)
- {
- if (!isFinite(num)) return 'Infinity';
- if(num < 1e3) return (Math.round((num*1000)/1000));
- var i = 0;
- var j = 0;
- while(num>=1e33){
- num/=1e30;
- j++;
- i=-1;}
- while(num >= 1000)
- {
- num/=1000;
- i++;
- }
- num = Math.round(num*1000)/1000;
- if(num>=1000)
- {
- num/=1000;
- i++;
- num = Math.round(num*1000)/1000;
- } //deals with rounding errors
- num = num.toString();
- if(num.indexOf('.') == -1) num += '.000';
- else
- {
- dec = num.indexOf('.');
- while(num.slice(dec,num.length).length < 4) num += '0'; //adds trailing 0s (if needed) to stop the numbers jumping around.
- }
- if(j=0) return num + nums[i - 1];
- return num + nums2[i] + nums3[j-1];
- }
- /* This takes you in infinity.
- ===--AUTOCLICK--===*/
- (function(){
- if(l('saveBox').innerHTML.indexOf('<select name="autoclick">') == -1){
- var somethingidk = '<select name="autoclick">';
- for(i in Game.clickables){
- if(Game.clickables[i].visible && Game.clickables[i].real){
- somethingidk+= "<option value=" + Game.clickables[i].key + '>' + Game.clickables[i].name + '</option>';
- }}
- somethingidk+= '</select>';
- return l('saveBox').innerHTML += somethingidk + "<div class='button' onclick='autoclick(1);'>Autoclick! (20/s)</div>" + "<div class='button' onclick='autoclick(0);'>Stop Autoclicking</div>";
- }}())
- autoclick=function(what){
- clearInterval(autoclicker);
- if(what==1){
- var click = document.getElementsByName('autoclick')[0].selectedOptions[0].value;
- autoclicker=setInterval(click.Click(), 50);}
- /* Yep, something original! If 20/s is too much, I suppose I could add a few slower options (8, 10, 12, 14, 16, 18, 22, 24, and 26?)*/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement