this post was submitted on 19 Jan 2025
11 points (100.0% liked)

Firefox

18372 readers
369 users here now

A place to discuss the news and latest developments on the open-source browser Firefox

founded 5 years ago
MODERATORS
 

I tried creating a single bookmark with search word But I can't get this to work. How can I bypass security to make it work ? Do I really have to enable debug mode ? Is it possible to switch debug mode without having to restart the browser (and discard all tabs)

Here is the code I tried

javascript:(async()=>{let t="S",n="GPT Classic",u="https://chatgpt.com/g/g-YyyyMT9XH-chatgpt-classic/?q=%25s",k="cc",g=(await PlacesUtils.bookmarks.search({parentGuid:PlacesUtils.bookmarks.toolbarGuid,title:t}))[0]?.guid||(await PlacesUtils.bookmarks.insert({parentGuid:PlacesUtils.bookmarks.toolbarGuid,title:t,type:PlacesUtils.bookmarks.TYPE_FOLDER})).guid;await PlacesUtils.bookmarks.insert({parentGuid:g,title:n,url:u}),await PlacesUtils.keywords.insert({keyword:k,url:u}),alert(`Bookmark "${n}" added to folder "${t}" with keyword "${k}"!`)})();

you are viewing a single comment's thread
view the rest of the comments
[–] MrOtherGuy 1 points 2 weeks ago

F12 opens web developer tools - the console there runs scripts in the website context - you cannot use that to access browser internals like PlacesUtils.

You need to run your script via browser console, I can't remember a hotkey for it, but you can find it from menu > more tools... > browser console

Also, I'm not sure but there's a chance that browser console is "read-only" in release firefox - meaning you might not be able to run anything from it. If that is the case, then open normal web developer tools (F12) and go to its settings, there's some checkbox there to enable "browser chrome debugging" or something like that. After checking that (and reopening browser console) you can run your function from browser console.