Created
July 5, 2021 15:34
-
-
Save meicookies/19ce2747a6d94cbd57922ec38a765a15 to your computer and use it in GitHub Desktop.
tinyurl shortener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/ruby | |
| # Coded by ./meicookies | |
| require 'open-uri' | |
| require 'json' | |
| class Tinyurl | |
| def single(url) | |
| url = JSON.parse(open("https://jar-api.xyz/api/short/tiny?url=#{url}&apikey=aichan").read) | |
| hasil = url["result"] | |
| puts hasil["link"] | |
| end | |
| def mass(file) | |
| File.readlines(file).each do |site| | |
| urlnya = JSON.parse(open("https://jar-api.xyz/api/short/tiny?url=#{site}&apikey=aichan").read) | |
| hasilnya = urlnya["result"] | |
| if "#{site}".match(/http/) | |
| puts "#{URI.parse(site.chomp).host}\t=> #{hasilnya["link"]}" | |
| else | |
| puts "#{site.chomp}\t=> #{hasilnya["link"]}" | |
| end | |
| File.open("url.txt", 'a').write("#{hasilnya["link"]}\n") | |
| end | |
| puts "saved on url.txt" | |
| end | |
| end | |
| perpendek = Tinyurl.new() | |
| if ARGV[0] == "-h" | |
| puts "[+] Usage: ./tinyurl.rb [option] <site/files>" | |
| puts "[+] Options: \n \t-u\tPaste Your site\n \t-l\tYour files website list\n \t-h\tDisplay this help command" | |
| elsif ARGV[0] == "-l" | |
| perpendek.mass(ARGV[1]) | |
| elsif ARGV[0] == "-u" | |
| perpendek.single(ARGV[1]) | |
| end |
Author
meicookies
commented
Jul 5, 2021

Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment