-
Notifications
You must be signed in to change notification settings - Fork 494
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bookmarklet #20
Comments
This is awesome! Just fyi, the bookmarklet version doesn't work. This does:
|
Btw this is an AWESOME idea! It's so useful for making complicated pages simple. This would also make a ncie extension. If only some websites were more semantic cough cough medium |
Thank you!
And thanks for fixing the bookmarklet. It did work for me in Firefox and iOS Safari.
… 8 apr. 2019 kl. 06:39 skrev Kognise ***@***.***>:
Btw this is an AWESOME idea! It's so useful for making complicated pages simple. This would also make a ncie extension
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or mute the thread.
|
@kognise Do we want to support this and add it to our docs somewhere? |
Love the idea of a bookmarklet! Already used it on some horrendous sites and it was awesome! 🎉 I'd really love to have the respective link in the README, so you can just drag & drop it from there into your favorites bar – but I didn't manage to escape the bookmarklet in a way that GitHub's markdown would accept it as URL. 😕 Anyhow, this would be an alternative implementation – minifies a little better (although this is admittedly not that important for a bookmarklet 😄) but also removes inline stylesheets and inline styles:
(escaped with Bookmarkleter and tested in Chrome & Firefox)¹ Beautified version:let doc = document
let $$ = selector => doc.querySelectorAll(selector)
let createElement = (tagName, properties) => Object.assign(doc.createElement(tagName), properties)
// Remove all CSS stylesheets, external and internal
$$('link[rel="stylesheet"],style').forEach(el => el.remove())
// Remove all inline styles
$$('*').forEach(el => (el.style = ''))
// Add water.css and responsive viewport (if necessary)
doc.head.append(
createElement('link', {
rel: 'stylesheet',
href: '//cdn.jsdelivr.net/gh/kognise/water.css@latest/dist/light.css',
}),
!$$('meta[name="viewport"]').length && createElement('meta', {
name: 'viewport',
content: 'width=device-width,initial-scale=1.0',
})
) Although I wonder if we even need to check whether a
|
In case this just doesn't work, we could add the link and drag-and-drop instructions to a separate HTML page (or simply the demo site) and then link to this page from within the READMA, à la: Want a bookmarklet to apply water.css to messy websites with a single click?Edit: Yup, GitHub simply doesn't allow |
That's too bad that it doesn't work in the README, but I think that the demo place is a good place to have it instead. I think we'd take a pull request with the bookmarklet added to the demo page if you wanted to make one! In the future, it would probably be best to have our Gulp build tools uglify the bookmarklet code at build time, but I think it's okay to just use the minified output from Bookmarkleter for now. Thanks for your work on this @jonaskuske! |
This should probably wait for #64 to merge before continuing - the bookmarklet code from above would have to change to point to the NPM release instead of the GitHub release. If someone wants to make a pull request ahead of time that adds the bookmarklet that points to the future NPM release, we could merge it once we publish to NPM. |
I'm gonna add this to the 2.0 milestone. |
I added the bookmarklet code as suggested by @jonaskuske to the repo in 9fb3225, but I'm gonna wait til #191 is merged to update the documentation site to avoid conflicts. Is there a better way to generate the bookmarklet then to manually use Bookmarkleter? |
Added this in c940d74! <3 |
Hi!
I really like the idea of a simple, plug-to-play theme, so I created a simple piece of JavaScript that removes all style sheets and replaces them with water.css (light by default), to be used as a bookmarklet on sites with terrible, unreadable style sheets. It also makes sure that the viewport is setup properly for mobile devices.
Here's the code for the bookmarklet that you can copy:
Here's the formatted code:
The text was updated successfully, but these errors were encountered: