Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //-----fetch memes
- fetch("https://api.imgflip.com/get_memes")
- .then(response=> response.json())
- .then(data=>{
- let array= data.data.memes;
- let meme= array[Math.floor(Math.random() * array.length)];
- let url= meme.url;
- let title= meme.name;
- let width= meme.width;
- let height= meme.height;
- let code= `<div id="meme">
- <h5>${title}</h5>
- <img src="${url}" style= "width:${width}px; height:${height}px"/>
- </div>`;
- select("pre").outerHTML="";
- select("pre").outerHTML= code;
- });
- //IP----
- let url1= "https://api.ip2country.info/ip?",
- url2= "https://api.ipify.org?format=json";
- let lol="";
- fetch(url2)
- .then(response=> response.json())
- .then(data=> {
- lol= data.ip;
- return fetch(url1 + data.ip);
- })
- .then(response=> response.json())
- .then(data=> alert(data.countryName +":"+ lol ))
- //----jokes
- fetch("https://v2.jokeapi.dev/joke/Any")
- .then(response=>response.json())
- .then(data=>{
- let joke= data.joke,
- joke1= data.setup,
- joke2= data.delivery;
- if(joke){
- alert(joke);
- }
- else{
- alert(joke1+"\n"+joke2);
- }
- })
- //----dictionary
- let url= "https://api.dictionaryapi.dev/api/v2/entries/en/",
- word= "HOME";
- fetch(url+word)
- .then(r=> r.json())
- .then(d=> {
- if(d.title){
- alert("Not found");
- }
- else{
- let xx= d[0].meanings[0].definitions[0].definition;
- let yy= d[0].meanings[1].partOfSpeech;
- alert(`${d[0].word} [${yy}]: ${xx}`);
- }
- })
- .catch(x=> alert(x));
- //--Always cors
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- let url= "https://random-d.uk/api/v2/random";
- let proxy= "https://cors.bridged.cc/";
- fetch(url)
- .then(r=> r.json())
- .then(d=> {alert(JSON.stringify(d))})
- .catch(x=> fetch(proxy+url))
- .then(r=> r.json())
- .then(d=> {img(d.url)})
- .catch(x=> alert(x))
- function img(src){
- if(select("#img")) select("#img").remove();
- let a= create("img");
- a.id="img";
- //a.style.cssText=`width:500%; height: 350px`;
- a.src= src;
- document.body.append(a);
- }
- //html parse-----
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- let url= "https://api.jokes.one";
- let url1= "https://krishan.ml/notepad";
- let proxy= "https://cors.bridged.cc/";
- fetch(url1)
- .then(r=> r.text())
- .then(d=> {
- var parser = new DOMParser();
- var doc = parser.parseFromString(d, 'text/html');
- alert(doc.querySelector("button").outerHTML);
- })
- //-----sn
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- let url= "https://m.starnieuws.com";
- let proxy= "https://cors.bridged.cc/";
- fetch(proxy+url)
- .then(r=> r.text())
- .then(d=> {
- let a= new DOMParser();
- let b= a.parseFromString(d, 'text/html');
- sn(b);
- })
- .catch(x=> alert(x))
- function sn(xo){
- let ul= select("ul",xo);
- let bx= selectAll("a",ul);
- bx.forEach(i=>{
- let a= create("a");
- /*a.href= i.href;
- a.text= i.text;
- document.body.append(a);*/ document.body.append(i)
- });
- }
- //---SN Latest Item
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- let urlz= "https://m.starnieuws.com";
- let proxy= "https://cors.bridged.cc/"
- fetch(proxy+urlz)
- .then(r=> r.text())
- .then(d=> {
- let a= new DOMParser().parseFromString(d,"text/html");
- let b= select("ul a",a);
- fetch(proxy+b.href)
- .then(r=> r.text())
- .then(d=> {
- let c= new DOMParser().parseFromString(d,"text/html");
- let x= window.open();
- let y= select("div[style='font-size: 25px']",c);
- x.document.write(y.innerHTML);
- })
- })
- .catch(x=> console.log(x))
- //--------urban dictionary
- fetch("https://api.urbandictionary.com/v0/define?term=lol")
- .then(r=>r.json())
- .then(d=>alert(d.list[0].definition))
- .catch(x=>alert(x))
- //----kovid19
- <div data-counter-value="8">8</div>
- <div>Overleden</div>
- <div data-counter-value="366">366</div>
- <div>Nieuwe gevallen vandaag</div>
- //---------
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- let nieuw= "//div[text()='Nieuwe gevallen vandaag']";
- let overl= "//div[text()='Overleden']";
- let Nieuw= document.evaluate(nieuw, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
- let Overl= document.evaluate(overl, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
- nieuwNum= Nieuw.previousElementSibling.innerHTML;
- overlNum= Overl.previousElementSibling.innerHTML;
- let message= `Overleden: ${overlNum}
- Nieuwe gevallen: ${nieuwNum}`;
- alert(message);
- //-------Covid19
- let create= (x)=> document.createElement(x),
- select= (x,y=document)=> y.querySelector(x),
- selectAll= (x,y=document)=> y.querySelectorAll(x);
- fetch("https://cors.bridged.cc/https://covid-19.sr")
- .then(r=> r.text())
- .then(d=> {
- let a= new DOMParser().parseFromString(d,"text/html");
- let Overl, Nieuw;
- selectAll("div",a).forEach(i=>{
- if(i.textContent== "Overleden") Overl= i;
- if(i.textContent== "Nieuwe gevallen vandaag") Nieuw= i;
- });
- let nieuwNum= Nieuw.previousElementSibling.dataset.counterValue;
- let overlNum= Overl.previousElementSibling.dataset.counterValue;
- let message= `Overleden: ${overlNum}
- Nieuwe gevallen: ${nieuwNum}`;
- alert(message);
- })
- .catch(x=> alert(x))
- //---
- let y= localStorage.getItem("nieuwnum");
- let dat= localStorage.getItem("dat");
- if(y!=nieuwNum) dat++;
- let message= `Overleden: ${overlNum}
- Nieuwe gevallen: ${nieuwNum}
- Datum: ${dat} oktober 2021`;
- alert(message);
- localStorage.setItem("nieuwnum", nieuwNum);
- localStorage.setItem("dat", dat);
- })
- //---diktionary
- function doit(x){
- let a= JSON.stringify(x);
- let word= x[0].word,
- phonetics= x[0].phonetic,
- origin= x[0].origin,
- audio= x[0].phonetics[0].audio;
- let mom= x[0].meanings;
- let dad= mom[0].definitions;
- let pos= mom[0].partOfSpeech,
- example= dad[0].example,
- synonym= dad[0].synonyms,
- antonym= dad[0].antonyms;
- alert(phonetics);
- }
- let options= {
- };
- let url="https://api.dictionaryapi.dev/api/v2/entries/en/home";
- let proxy= "https://cors.bridged.cc/";
- fetch(url,options)
- .then(r=> r.json())
- .then(d=> doit(d))/*
- .catch(x=> fetch(proxy+url,options))
- .then(r=> r.json())
- .then(d=> doit(d))
- .catch(x=> alert(x))*/
- /*
- "word":"hose",
- "phonetic":"həʊz",
- "phonetics":[
- {"text":"həʊz",
- "audio":"//ssl.gstatic.com/dictionary/static/sounds/20200429/hose--_gb_1.mp3"
- }],
- "origin":"only to the ankle.",
- "meanings":[
- {"partOfSpeech":"noun",
- "definitions":[
- {"definition":"a flexible tube ",
- "example":"a sprinkler hose",
- "synonyms": ["pipe","piping"],
- "antonyms":[]
- },
- {"definition":"suse",
- "example":"her hose had been laddered",
- "synonyms":[],
- "antonyms":[]
- }
- ]},
- {"partOfSpeech":"verb",
- "definitions":[
- {"definition":"water or spray with a hose.",
- "example":"he was hosing down the driveway",
- "synonyms":[],
- "antonyms":[]
- }]
- }]
- */
- //Dictionary
- [
- {
- "word": "hello",
- "phonetics": [
- {
- "text": "/həˈloʊ/",
- "audio": "https://lex-audio.useremarkable.com/mp3/hello_us_1_rr.mp3"
- },
- {
- "text": "/hɛˈloʊ/",
- "audio": "https://lex-audio.useremarkable.com/mp3/hello_us_2_rr.mp3"
- }
- ],
- "meanings": [
- {
- "partOfSpeech": "exclamation",
- "definitions": [
- {
- "definition": "Used as a greeting or to begin a phone conversation.",
- "example": "hello there, Katie!"
- }
- ]
- },
- {
- "partOfSpeech": "noun",
- "definitions": [
- {
- "definition": "An utterance of “hello”; a greeting.",
- "example": "she was getting polite nods and hellos from people",
- "synonyms": [
- "greeting",
- "welcome",
- "salutation",
- "saluting",
- "hailing",
- "address",
- "hello",
- "hallo"
- ]
- }
- ]
- },
- {
- "partOfSpeech": "intransitive verb",
- "definitions": [
- {
- "definition": "Say or shout “hello”; greet someone.",
- "example": "I pressed the phone button and helloed"
- }
- ]
- }
- ]
- }
- ]
- //-------
- let word= data[0].word,
- phonetics= data[0].phonetics,
- meanings= data[0].meanings;
- //Phonetics
- let pron1= phonetics[0].text,
- audio1= phonetics[0].audio;
- let pron2= phonetics[1].text,
- audio2= phonetics[1].audio;
- //Meanings
- let pos1= meanings[0].partOfSpeech;
- let definitions1= meanings[0].definitions;
- let def1= definitions1[0].definition;
- let ex1= definitions1[0].example;
- let pos2= meanings[1].partOfSpeech;
- let definitions2= meanings[1].definitions;
- let def2= definitions1[1].definition;
- let ex2= definitions1[1].example;
- let syn= definitions1[1].synonyms; //array
- let pos3= meanings[2].partOfSpeech;
- let definitions3= meanings[2].definitions;
- let def3= definitions1[2].definition;
- let ex3= definitions1[2].example;
- //-------------->>>>>>
- function doit(x){
- let a= JSON.stringify(x);
- let word= x[0].word,
- phonetics= x[0].phonetic,
- origin= x[0].origin,
- audio= x[0].phonetics[0].audio;
- let mom= x[0].meanings;
- let dad= mom[0].definitions;
- let pos= mom[0].partOfSpeech,
- example= dad[0].example,
- synonym= dad[0].synonyms,
- antonym= dad[0].antonyms;
- alert(phonetics);
- }
- let options= {
- };
- let url="https://api.dictionaryapi.dev/api/v2/entries/en/home";
- let proxy= "https://cors.bridged.cc/";
- fetch(url,options)
- .then(r=> r.json())
- .then(d=> doit(d))/*
- .catch(x=> fetch(proxy+url,options))
- .then(r=> r.json())
- .then(d=> doit(d))
- .catch(x=> alert(x))*/
- /*
- "word":"hose",
- "phonetic":"həʊz",
- "phonetics":[
- {"text":"həʊz",
- "audio":"//ssl.gstatic.com/dictionary/static/sounds/20200429/hose--_gb_1.mp3"
- }],
- "origin":"only to the ankle.",
- "meanings":[
- {"partOfSpeech":"noun",
- "definitions":[
- {"definition":"a flexible tube ",
- "example":"a sprinkler hose",
- "synonyms": ["pipe","piping"],
- "antonyms":[]
- },
- {"definition":"suse",
- "example":"her hose had been laddered",
- "synonyms":[],
- "antonyms":[]
- }
- ]},
- {"partOfSpeech":"verb",
- "definitions":[
- {"definition":"water or spray with a hose.",
- "example":"he was hosing down the driveway",
- "synonyms":[],
- "antonyms":[]
- }]
- }]
- */
Advertisement
Add Comment
Please, Sign In to add comment