Giter Site home page Giter Site logo

thedeveloper / bookmarklet-maker Goto Github PK

View Code? Open in Web Editor NEW

This project forked from caiorss/bookmarklet-maker

0.0 0.0 0.0 22 KB

Tool to create bookmarklet/ javascript apps to automate the web browser.

Home Page: http://caiorss.github.io/bookmarklet-maker

License: The Unlicense

HTML 100.00%

bookmarklet-maker's Introduction

Bookmarklet Maker

Overview

Bookmarklet maker is a small web app to create bookmarklet or small executable Javascript apps to peform browser automation tasks.

You can run this app by accessing the hyperlink:

If you don’t know what is a bookmarklet, see:

Bookmarklet Cheat Sheet

Get Metadata

Get current page title

<title>Paget Title</title>
document.title

Get author

<meta content="author M.r dummy" name="author">
Array.from(document.getElementsByTagName("meta"))
    .find(function(e){return e.name == "author"})
    .content

Get description

<meta content="A description of the page." name="description">
Array.from(document.getElementsByTagName("meta"))
    .find(function(e){return e.name == "description"})
    .content

Get keywords

<meta content="keyword1 keyword2 keyword2" name="keywords">
Array.from(document.getElementsByTagName("meta"))
    .find(function(e){return e.name == "keywords"})
    .content

Get current date

> var d = new Date() ; (d.getYear() + 1900).toString() + "-" + d.getMonth().toString() + "-" + d.getDay().toString()
"2016-9-4"

Function getDate()

function getDate(){
    var d = new Date();
    return (d.getYear() + 1900).toString() + "-" +
        d.getMonth().toString() + "-" + d.getDay().toString() ;
}

>> getDate()
"2017-3-5"

Url

Get current page URL

document.URL

Redirect current page

window.location.href = "http://www.httpbin.org/get"

Open url in a new tab

window.open("http://www.yandex.com")

URL manipulation

URL Manipulation is useful to send the current URL to some web service or Web App such as Google Driver or Web Archive.

  • Open some page that doesn’t exist anymore in Web Archive:
var baseUrl = "https://web.archive.org/web/*/"
var urlmod  = document.URL
window.location.href = baseUrl + urlmod
  • Open a file google Driver.

Example URL: https://drive.google.com/viewerng/viewer?url=lampwww.epfl.ch/~hmiller/scala2014/proceedings/p51-prokopec.pdf

var baseUrl = "http://lampwww.epfl.ch/~hmiller/scala2014/proceedings/p51-prokopec.pdf"
var urlmod = "https://drive.google.com/viewerng/viewer?url=" + baseUrl
window.open(urlmod)

Open current page (PDF document in Google Driver).

window.open("https://drive.google.com/viewerng/viewer?url=" + document.URL);

Open a prompt showing Google driver URL to current document. Useful to create short URL in services like tiny URL and view document in Tablets or Smartphones.

prompt("Google driver URL:", "https://drive.google.com/viewerng/viewer?url=" + document.URL);

Misc

Display alert box (Messagebox)

alert("My message");

Display a prompt

  • The promopt function is useful to read user input and allow user to copy some data.
prompt("Window title", "Content")

Display string in console

console.log(object);
console.log("My message");

Style

Recipes

Generate org-mode Bibliographical Reference

function getDate(){
    var d = new Date()
    return (d.getYear() + 1900).toString() + "-" +
        d.getMonth().toString() + "-" + d.getDay().toString() ;
};


var text = '*' + document.title + '*' + " Accessed at " + getDate() +
    ". Available at <" + document.URL + "> " ;

prompt("Type Ctrl+A and Ctrl+C to copy the markdown", text);

It will generate a reference like this:

- *Overview of Forks, Threads, and Asynchronous I/O* Accessed at 2017-3-5. Available at <http://www.remwebdevelopment.com/blog/overview-of-forks-threads-and-asynchronous-io-133.html> 

Change the page width for better readability

This will set the page width to the width of an A4 ISO paper sheet that makes easier to read long texts in the browser.

document.querySelector("body").style.setProperty("width", "800px")

Invert page color for enhancing reading at night

document.querySelector("body").style.setProperty("color", "white")
document.querySelector("body").style.setProperty("background", "black")

Change page background color

document.querySelector("body").style.setProperty("background", "white")

See also:

bookmarklet-maker's People

Contributors

caiorss avatar thedeveloper avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.