Skip to content

Bookmarklet

Richard Frost edited this page May 17, 2020 · 13 revisions

Advanced Profanity Filter (APF) Bookmarklet

When you can't install the extension but would still like to filter a webpage, your best option is to use the Advanced Profanity Filter (APF) Bookmarklet. To create a personal bookmarklet with your configuration, navigate to the extension's Options page and open the Bookmarklet tab.

Pros:

  • Runs on most browsers, including mobile Google Chrome and iOS Safari
  • Only runs when you want it (must manually activate the bookmarklet)
  • Compatible with the same configuration as the extension

Cons:

  • Not run automatically; you have to run the bookmarklet on each page and every reload
  • No UI to modify settings
  • No auto-updating

Bookmarklet with Default Settings

If you just want a quick profanity filter or are happy with the default settings, you can create a new bookmark, give it a name such as APF, and place the following in the URL field:

javascript:(function()%7Bif(!document.querySelector(%22script.apfBookmarklet%22))%7Blet%20apfScriptEl%3Ddocument.body.appendChild(document.createElement(%22script%22))%3BapfScriptEl.type%3D%22text%2Fjavascript%22%3BapfScriptEl.src%3D%22https%3A%2F%2Fcdn.jsdelivr.net%2Fgh%2Frichardfrost%2FAdvancedProfanityFilter%40master%2Fbookmarklet.js%22%3BapfScriptEl.className%3D%22apfBookmarklet%22%3B%7D%7D)()

Read through the usage section for instructions on how to use it. If you would like to use your own configuration, please read through the setup section.

Setup

  1. Navigate to the Advanced Profanity Filter Option page.
  2. Download the APF Bookmarklet File (Click the button in the Bookmarklet tab).
  3. Host the file publicly click on a link for instructions on how to use your desired service
  4. Paste the link to the hosted file (from step 3) into the Hosted File URL box in the Bookmarklet's option tab.
  5. Save the APF Bookmarklet to your browser (Found at the bottom of the Bookmarklet's option tab, named APF). This can be done by dragging it to your browser's Bookmark bar or by right-clicking and copying the link destination and saving that to a bookmark.
    • If you have browser bookmark syncing enabled this may copy to your desired device/browser automatically.
    • Alternatively, you can copy the bookmarklet link and add it to your desired device/browser as a bookmark. If you don't know how to do that check the documentation for your browser.

Usage

Android Google Chrome Mobile

To activate the APF Bookmarklet filter you will need to browse to the desired page and then from the Omnibox (address bar) start typing your bookmark's name (example: APF) and then select it. Using the bookmark manager on Chrome Mobile doesn't allow bookmarklets to run.

iOS Safari (iPod/iPhone/iPad)

To activate the APF Bookmarklet filter, browse to the desired page, open your Bookmarks and then tap on the bookmarklet.

Other

This varies between browsers and devices, but typically you can just select/activate it by tapping/clicking on it. Search for "Bookmarklets on device/browser name" for more information on your particular case.

Updates

To update your settings or the version of the filter, you will need to repeat Setup steps 1-3. If you update the file from step 2 as just an update/new version you won't need to complete the steps 4-5. The APF Bookmarklet uses the same codebase as the extension, so when a new version of the extension is released it is recommended that you update your APF bookmarklet file. If you modify your settings (example: add a new word to filter) you will also need to update the bookmarklet file.

Hosting Your Bookmarklet File

Your Bookmarklet code can be hosted anywhere where it is publicly accessible, but you will need to supply a download link, not a link to view the file. Below are a couple examples, but there are countless other services that you could use. Regardless of which service you use, you can test the URL by opening it in an Incognito/Private browser window and make sure its accessible and either plain text or a file download.

Google Drive

Requires a Google account

If you supply a link like https://drive.google.com/file/d/<id>/view?usp=sharing... it will be automatically converted to a download link.

  1. Upload the file to Google Drive
  2. Right click on the file and then select Share...
  3. Click Advanced in the bottom right corner
  4. Under the Who has access options click on Change
  5. Select On – Public on the web and then Save
  6. Copy that link into Setup step 4 (Hosted File URL text box)

If you need to get the download URL manually, follow these steps:

  1. Copy the file ID you can find in the text field at the top of the window
    • The ID is found between https://drive.google.com/file/d/ and /view?usp=sharing...
  2. The public URL to your file will be https://drive.google.com/uc?export=view&id= and then your ID from step 6

Dropbox

Requires a Dropbox account

If you supply a link like https://www.dropbox.com/s/<id>/filename?dl=0 it will be automatically converted to a download link.

  1. Upload the file to Dropbox
  2. Select the file and then choose the Share button
  3. Select Create a link in the bottom right corner
  4. Click Copy link (or copy it manually) and then close the modal and use the link in Setup step 4 (Hosted File URL text box)

If you need to get the download URL manually, follow these steps:

  1. Change www.dropbox.com to dl.dropbox.com and ?dl=0 to ?raw=1

Github Gist

Requires a GitHub account

If you supply a link like one of these it will be automatically converted to a download link:

  • https://gist.github.com/<username>/<gist_id>
  • https://gist.githubusercontent.com/<username>/<gist_id>/raw/<revision_id>/apfBookmarklet.js
  1. Create a new Gist
  2. Drag the file from step 1 in the Setup section into the window, or click Add file
    • Alternatively copy the contents of that file into the Gist and provide a filename, such as apfBookmarklet.js
  3. Click the Create secret gist button (or choose public you would like)
  4. After being redirected to the gist, copy the URL from the address bar into Setup step 4

If you need to get the download URL manually, follow these steps:

  1. Copy the ID from the URL in step 4
    • The ID is everything after https://gist.github.com/USERNAME/
  2. The public download URL for your file will be https://gist.githubusercontent.com/, and then your USERNAME, followed by a / and then the ID, and finally end with /raw/ and then the filename (if the gist only has 1 file it the filename can be omitted).
    • Example: https://gist.githubusercontent.com/<USERNAME>/<ID>/raw/apfBookmarklet.js

Other Notes

All extension API calls have been removed or are short-circuited. This has the following effects:

  • No word count (showCounter) or summary (showSummary) for filtered words
  • If muteAudio is true, muteMethod is forced to 1 (mute video volume)
Clone this wiki locally