Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Bookmarklets doesn't work from bookmarks #2871

Closed
LittleAngelwings opened this issue May 27, 2019 · 45 comments
Closed

Bookmarklets doesn't work from bookmarks #2871

LittleAngelwings opened this issue May 27, 2019 · 45 comments
Labels
🐞 bug Crashes, Something isn't working, .. Feature:FennecTransition P2 Upcoming release pin Issues, features, improvements that are still valid

Comments

@LittleAngelwings
Copy link

LittleAngelwings commented May 27, 2019

Steps to reproduce

Save any site to bookmarks
Edit this bookmark and put in there a Javascript as url, e.x.
javascript:%20(function%20()%20{%20%20%20%20%20%20window.open('https://invidio.us/watch?v='%20+%20document.location.href.replace(/^.+v=(.{11})(.+)?/g,%20'$1'));%20%20})();
Save this edited bookmark
Use it on YouTube for download a video.

Expected behavior

The YT Video will be downloaded

Actual behavior

The url of the bookmarklet will be searched

Device information

  • Android device: Samsung Galaxy Tab SM-T580 and Huawei P smart
  • Fenix version: 1.0.1921 Nightly and Raptor

┆Issue is synchronized with this Jira Task

@LittleAngelwings LittleAngelwings added the 🐞 bug Crashes, Something isn't working, .. label May 27, 2019
@vesta0 vesta0 added the P2 Upcoming release label May 30, 2019
@vesta0 vesta0 added this to the Bugs milestone May 30, 2019
@bobobo1618
Copy link

I'm also able to reproduce this.

Annoyingly, typing javascript: URLs into the address bar results in a Google search.

@boek boek removed this from the Bugs and Polish milestone Jul 17, 2019
@vesta0 vesta0 removed this from the Bugs and Polish milestone Jul 24, 2019
@data-sync-user data-sync-user changed the title [Bug] Bookmarklets doesn't work from bookmarks FNX3-16640 ⁃ [Bug] Bookmarklets doesn't work from bookmarks Aug 11, 2020
@kbrosnan kbrosnan changed the title FNX3-16640 ⁃ [Bug] Bookmarklets doesn't work from bookmarks [Bug] Bookmarklets doesn't work from bookmarks Aug 26, 2020
@mindeffects
Copy link

mindeffects commented Sep 29, 2020

Fun fact 1: When using the Developer Edition of Firefox, everything works as expected.
Fun fact 2: I spent 2 hours preparing a super luxury preview bookmarklet in FFdev which completly failed when the client wanted to use it in his browser (Firefox Regular Edition). :-D

@cadeyrn
Copy link
Contributor

cadeyrn commented Sep 29, 2020

@mindeffects There is no "Developer Edition" of Firefox for Android. Are you talking about Firefox for Desktop? Or do you mean the nightly builds of Firefox for Android when you say "Developer Edition"?

@mindeffects
Copy link

Oh, sorry. I typed the post on my mobile and mighted have stumbled into the wrong thread... Damn you, small screen! 😉
I had my problem with the desktop version of FF for macOS. Sorry.

@mdxe
Copy link

mdxe commented Oct 11, 2020

I have the same issue and most extensions don't work... Also having the same issue in the nightly build.

Why did they even release this as a final version? As a work-around, I switched back to Fennec v68.11.0esr ... to be able to use my extensions and bookmarklets.

@angelsl
Copy link

angelsl commented Nov 22, 2020

How do I help out with this? Is this blocked on some design issue or does someone just need to write it out?

@theabbie
Copy link

theabbie commented Jan 4, 2021

Is it fixed yet? If this is for security reasons atleast allow people to disable it.

@mdxe
Copy link

mdxe commented Jan 4, 2021

Is it fixed yet? If this is for security reasons at least allow people to disable it.

Mozilla just fired 1/4 of its employees and stopped caring about their core users (the only ones that haven't switched to Chrome)...

@theabbie
Copy link

theabbie commented Jan 4, 2021

@mdxe That's irrelevant, this was an existing feature they disabled.

@angelsl
Copy link

angelsl commented Jan 4, 2021

@mdxe That's irrelevant, this was an existing feature they disabled.

@theabbie Did they actually disable it, or was it simply never implemented in Fenix?

I think it's the latter.

@theabbie
Copy link

theabbie commented Jan 4, 2021

@angelsl Maybe it's the latter only, in chrome though, there is a workaround, you can call the bookmarklet from address bar. Bookmarklets are useful and should be allowed.

@mdxe
Copy link

mdxe commented Jan 4, 2021

@mdxe That's irrelevant, this was an existing feature they disabled.

I switched back to Fennec, and extensions and bookmarlets work fine on Android (but I get no updates). I think it never worked on Fenix.

@thomasleplus
Copy link

Just my 2 cents: I was regularly relying on bookmarklets previously so I was surprised/desappointed when they stopped working. I hope the feature is brought back soon, although I understand it's probably lower in the list of priorities than other, more widely-used features.

Thanks to everyone who's contributing.

@KrasnayaPloshchad
Copy link

KrasnayaPloshchad commented Apr 2, 2021

It would be nice if Fenix got this support, this would make Fenix being able to share the web page using following bookmarklets, without any extension and external app:
https://wantora.github.io/qrcode-bookmarklet/
https://ctrlq.org/ios/?qr
https://www.addtoany.com/users/bookmarklet
https://www.shareaholic.com/tools/bookmarklet/

@Obscerno
Copy link

Obscerno commented May 3, 2021

I've been following this issue waiting for it to be resolved, but I just realised this morning that on Firefox Nightly for Android, my bookmarklets are working again. I just thought I'd let people know who were following this issue for the same reason as me.

@KrasnayaPloshchad
Copy link

Unfortunately, all booksmarklets on my comment failed to work.

90.0a1 (Build #2015808363)
AC: 90.0.20210503143138, a9e5357a4
GV: 90.0a1-20210503094544
AS: 75.2.0

@Obscerno
Copy link

Obscerno commented May 4, 2021

Unfortunately, all booksmarklets on my comment failed to work.

I just tested the shareaholic one and it worked for me. Are you pasting the bookmarklet directly into the url? If so that doesn't work. What I had to do was:

  • Hit the bookmark button in the menu on a normal page.
  • Edit the new bookmark, and replace the url with the bookmarklet script. Change the name to something easy to remember.
  • To use it, type the name of the bookmark in the address bar and tap the suggestion. Annoyingly, for me my bookmarks show up at the veeeerry bottom of the suggestions list.

Not very intuitive at all, but it works for me. I hope it helps!

@jaywink
Copy link

jaywink commented May 5, 2021

Confirmed to work an Firefox 88.1.2 🎉 As per above, via the address bar, not via bookmarks.

Something has changed for the better when clicking a bookmarklet in the bookmarks though - it now for me actually navigates to the right page but the the JS that tries to grab the page title + url before doing that doesn't seem to work, and they come out blank. Using the address bar it all works. The bookmarklet I'm testing with is:

javascript:var bookmarklet=function(h,d,k,b){var a=1900,g=128,j=function(){var i=window,l=i.screenTop?i.screenTop:i.screenY,c=i.screenLeft?i.screenLeft:i.screenX;return"width="+d+",height="+k+",top="+(l+i.innerHeight/2-k/2)+",left="+(c+i.innerWidth/2-d/2)},f=function(){var r=window,w=document,p=r.location.href,u=w.title,v=r.getSelection?r.getSelection():w.getSelection?w.getSelection():w.selection.createRange().text,i=v.toString(),q=a-p.length;return(u+i).length>q&&(u.length>g&&(u=u.substr(0,g)+" ..."),i.length>q-g&&(i=i.substr(0,q-g)+" ...")),"url="+encodeURIComponent(p)+"&title="+encodeURIComponent(u)+"&notes="+encodeURIComponent(i)},m=function(){var e=b||"location=yes,links=no,scrollbars=yes,toolbar=no",c=h+"?jump=yes";window.open(h+"?"+f(),"socialhome_bookmarklet",e+","+j())||(window.location.href=c+"&"+f())};/Firefox/.test(navigator.userAgent)?setTimeout(m,0):m()};bookmarklet("https://jasonrobinson.me/bookmarklet",620,400);

@SoftVision-LorandJanos
Copy link

It would be nice if Fenix got this support, this would make Fenix being able to share the web page using following bookmarklets, without any extension and external app: https://wantora.github.io/qrcode-bookmarklet/ https://ctrlq.org/ios/?qr https://www.addtoany.com/users/bookmarklet https://www.shareaholic.com/tools/bookmarklet/

Verified as fixed on the latest Nightly 98.0a1 (2022-02-08) using the examples mentioned in this comment.
Device used: Oppo Reno 6 (Android 11).
Closing the ticket as fixed.

@Obscerno
Copy link

@SoftVision-LorandJanos or @rocketsroger Could we get this reopened? The fix was reverted: #13336 (comment)

@czlucius
Copy link
Contributor

Perhaps you want to close this issue?
Bookmarklets are working from bookmarks already since the patch
Thanks

@czlucius
Copy link
Contributor

@SoftVision-LorandJanos
Can you verify the fix and close the issue?
Thanks

@snarfed
Copy link

snarfed commented Jun 20, 2022

@czlucius which version did your patch ship in? I'm on 101.2.0, stable, the current version available on the Play Store, and bookmarklets aren't working for me. I've tried the one in the original issue description here and a number of others, first creating any bookmark, editing it and pasting in the bookmarklet contents (without spaces), and then trying to load it by typing its name in the address bar, as described in #2871 (comment) . No luck.

Screenshot_20220620-071059.png

@czlucius
Copy link
Contributor

Screen_Recording_20220620-225708_Firefox.mp4

The issue was about opening bookmarklets from the bookmarks menu, I tried a bookmarklet and it works.
Maybe some bookmarklets don't work?

@czlucius
Copy link
Contributor

Pasting in the address bar also works

@jnv
Copy link

jnv commented Jun 20, 2022

@snarfed This may also depend on the Content Security Policy (CSP) of the website where you try to run the bookmarklet. CSP can block 3rd party scripts (including bookmarklets) from running. However that's a known issue unrelated to this one and it affects also the desktop Firefox, see Bugzilla.

@czlucius
Copy link
Contributor

I notice that the bookmarklets may not be able to open new tabs (window.open), perhaps due to popup blocking

@snarfed
Copy link

snarfed commented Jun 20, 2022

@czlucius aha, that might be part of it, one bookmarklet I've been testing tried to open a new window. But the bookmarklet in the original description here changes the current tab's location, and it doesn't work for me either. Does pop-up blocking also block that? Is there any way to modify pop-up blocking on mobile?

@snarfed
Copy link

snarfed commented Jun 20, 2022

I tried the bookmarklet posted earlier here that removes CSS, and it works, so pop-up blocking (and blocking changing the current window's location) probably are the issues after all.

Bookmarklets that open new windows or change the current tab's location work ok right now on desktop. Any ideas what we could do to get them working on mobile?

@czlucius
Copy link
Contributor

czlucius commented Jun 23, 2022

javascript:%20(function%20()%20{%20%20%20%20%20%20window.open('https://invidio.us/watch?v='%20+%20document.location.href.replace(/^.+v=(.{11})(.+)?/g,%20'$1'));%20%20})();
(As posted in original post)
Opens a new tab.

Changing current tab URL works
(this modified bookmarklet):
javascript: (function () { document.location.href = ('https://invidio.us/watch?v=' + document.location.href.replace(/^.+v=(.{11})(.+)?/g, '$1')); })();

@lazymonkey2
Copy link

does it work this bookmarklet used to add new bookmarks to BookmarkOS ?
You can found it here:
https://www.bookmarkos.com/bookmarklet
Code:
javascript:(function(){ var metas = document.getElementsByTagName('meta'); var metaInfo = {}; var metaDescription = null; var ogDescription = null; var twitterDescription = null; var ogType = null; var metaKeywords = null; for (var i=0; i<metas.length; i++) { var meta = metas[i]; if (meta.getAttribute('name') == 'description'){ metaDescription = metas[i].getAttribute('content'); } else if (meta.getAttribute('property') == 'og:description'){ ogDescription = metas[i].getAttribute('content'); } else if (meta.getAttribute('name') == 'twitter:description'){ twitterDescription = metas[i].getAttribute('content'); } else if (meta.getAttribute('property') == 'og:type'){ ogType = metas[i].getAttribute('content'); } else if (meta.getAttribute('name') == 'keywords'){ metaKeywords = metas[i].getAttribute('content'); } } metaInfo['meta_description'] = metaDescription || ogDescription || twitterDescription; metaInfo['meta_keywords'] = metaKeywords; metaInfo['og_type'] = ogType; var dualScreenLeft = window.screenLeft != undefined ?%20window.screenLeft%20:%20screen.left;%20var%20dualScreenTop%20=%20window.screenTop%20!=%20undefined%20?%20window.screenTop%20:%20screen.top;%20width%20=%20window.innerWidth%20?%20window.innerWidth%20:%20document.documentElement.clientWidth%20?%20document.documentElement.clientWidth%20:%20screen.width;%20height%20=%20window.innerHeight%20?%20window.innerHeight%20:%20document.documentElement.clientHeight%20?%20document.documentElement.clientHeight%20:%20screen.height;%20var%20left%20=%20((width%20/%202)%20-%20(750%20/%202))%20+%20dualScreenLeft;%20var%20top%20=%20((height%20/%202)%20-%20(450%20/%202))%20+%20dualScreenTop;%20%20window.open(%27https://bookmarkos.com/save?url=%27+encodeURIComponent(location.href)+%27&title=%27+encodeURIComponent(document.title)+%27&meta_description=%27%20+%20encodeURIComponent(metaInfo[%27meta_description%27])+%27&meta_keywords=%27%20+%20encodeURIComponent(metaInfo[%27meta_keywords%27])+%27&og_type=%27%20+%20encodeURIComponent(metaInfo[%27og_type%27]),%20%27bookmark%27,%20%27left=%27%20+%20left+%20%27,top=100,width=750,height=450,toolbar=0,location=0,resizable=0%27);%20})();

@stale
Copy link

stale bot commented Dec 20, 2022

See: #17373 This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Dec 20, 2022
@lazymonkey2
Copy link

issue still present. please do not close.

@stale stale bot removed the wontfix label Dec 20, 2022
@qcasey
Copy link

qcasey commented Dec 20, 2022

Changing current tab URL works

Confirmed, changing window.open to document.location.href= works for several of my bookmarklets

@jonalmeida jonalmeida added pin Issues, features, improvements that are still valid and removed eng:qa:verified QA Verified labels Dec 21, 2022
@csadilek csadilek changed the title [Bug] Bookmarklets doesn't work from bookmarks Bookmarklets doesn't work from bookmarks Jan 20, 2023
@csadilek
Copy link
Contributor

Moved to bugzilla: https://bugzilla.mozilla.org/show_bug.cgi?id=1811582

Change performed by the Move to Bugzilla add-on.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
🐞 bug Crashes, Something isn't working, .. Feature:FennecTransition P2 Upcoming release pin Issues, features, improvements that are still valid
Projects
None yet
Development

No branches or pull requests