Category Archives: Browser

What to Expect When Expecting Content Security Policy Reports

Content Security Policy (CSP) allows you to dictate a policy for content restrictions on a web site that is enforced by the browser. By setting a CSP header, can control the resources that are loaded when a visitor is viewing your website. The CSP spec allows you to build very specific policies for your site that can handle all of the different types of resources that a site might load. It is a valuable tool for protecting your site visitors.

In addition to blocking resources that violate the defined CSP, the CSP spec details a mechanism for sending reports of such violations. Monitoring these violations can help you ensure that your site is never serving content that violates your wishes whether those violations are the result of producer, developer, or hacker actions.

Source: What to Expect When Expecting Content Security Policy Reports

Prevent new window from hiding addons in toolbar | Firefox Support Forum | Mozilla Support

Hi Jerl, you don’t need to explain the problem to me. I still have dom.disable_window_open_feature.toolbar set to true in about:config although it no longer does anything. As support forum volunteers, we don’t get special access to developers, we have to get in line like everyone else.


Did I post this before? The reason the toolbar buttons are hidden is a built-in style rule. So as an unofficial community developed workaround, you can inject an overriding style rule to make them visible again.

Setting this up is a little bit involved, so please set aside 10 quiet minutes to work through it.

(For anyone who already has a userChrome.css file set up, you just need to add the rule under (A) to your file.)

(A) Select and copy the following style rule code

/* Override Hiding of Toolbar Buttons in Limited Feature Windows */
*|*:root[chromehidden~="toolbar"] .chromeclass-toolbar-additional {
  display: -moz-box !important; /* default is display: none */
}

(B) Generate and download a userChrome.css file

Open the following page and paste the above rules into the editor, replacing the sample rule:

https://www.userchrome.org/download-userchrome-css.html

Then click “Generate CSS File” and save the userChrome.css file to your computer. (See first attached screenshot)

Use the downloads list on the toolbar to open the downloads folder directly to the new userChrome.css file. (See second attached screenshot)

Minimize that file browser window for later reference.

(C) Create a new chrome folder in your profile folder

The following article has the detailed steps for that (#1, #2, and I recommend #3)

https://www.userchrome.org/how-create-userchrome-css.html

I have videos for both Windows and Mac in case the text is not clear.

(D) Move the userChrome.css file you downloaded in Step B into the chrome folder you created in Step C

(E) Set Firefox to look for userChrome.css at startup — see step #6 in the above article.

The next time you exit Firefox and start it up again, it should discover that file and apply the rule.

Success?

Once you start tweaking the interface this way, you’ll probably find more and more things you want to do. I suggest bookmarking the pages where you get the code for future reference because changes to Firefox may break them and it’s easier to request an update if you can find the source.

Source: Prevent new window from hiding addons in toolbar | Firefox Support Forum | Mozilla Support

A brief guide to Mozilla preferences – Mozilla | MDN

What is a preference?

A preference is any value or defined behavior that can be set (presumably, one setting is preferable to another). Preference changes via user interface usually take effect immediately. The values are saved to the user profile (in prefs.js), for both Firefox and Thunderbird.

A preference is read from a file, and can call up to four methods: pref()user_pref(), sticky_pref() and lockPref(). All preferences files may call pref()user_pref() and sticky_pref(), while the config file in addition may call lockPref().

Source: A brief guide to Mozilla preferences – Mozilla | MDN

How to Create a userChrome.css File

How to Create a userChrome.css File

Updated May 24, 2019; Originally posted by jscher2000 on November 5, 2017.

Creating your userChrome.css file is the first step on your quest to make over Firefox’s interface. It takes a couple of minutes, but it’s important to take your time and get it right so Firefox loads and applies your style recipes on the first try.

At startup, Firefox will check for the userChrome.css file in a particular location: a folder named chrome inside your currently active profile folder. The profile folder is where all of your current settings and add-ons are stored. (If you want to learn more about that folder, see “Profiles — Where Firefox stores your bookmarks, passwords and other user data” on Mozilla Support.)

Here’s how you set that up (full details below):

  1. Open your currently active profile folder
  2. Create a new folder named chrome
  3. Create a desktop shortcut (alias) to the chrome folder for easier future access
  4. Make sure your OS is set to show you file extensions like .txt and .css
  5. Create a new text file inside the chrome folder named userChrome.css
  6. Change a preference in Firefox so it looks for your files at startup (in Firefox 69+)

Source: How to Create a userChrome.css File

mod_rewrite Cheat Sheet by DaveChild

A mod_rewrite Cheat Sheet – a quick reference guide for mod_rewrite, with rewrite flags, regular expression syntax and sample rules.

mod_re­write Tutorials

mod_re­write Rewrit­eRule Flags

C
Chained with next rule
CO=cookie
Set specified cookie
E=var:­value
Set enviro­nmental variable “var” to “value”
F
Forbidden (403 header)
G
Gone – no longer exists
H=handler
Set handler
L
Last – stop processing rules
N
Next – continue processing
NC
Case insens­itive
NE
Do not escape output
NS
Ignore if subrequest
P
Proxy
PT
Pass through
R[=code]
Redirect to new URL, with optional code (see below)
QSA
Append query string
S=x
Skip next x rules
T=mime­-type
Set mime type

mod_re­write Rewrit­eCond Flags

NC
Case insens­itive
OR
Combine with next rule using ‘OR’ instead of the default of ‘AND’

Redire­ction Header Codes

301
Moved perman­ently
302
Moved tempor­arily (default)

mod_re­write Directives

Rewrit­eEngine
RewriteMap
Rewrit­eOp­tions
Rewrit­eBase
RewriteLog
Rewrit­eCond
Rewrit­eLo­gLevel
Rewrit­eRule
Rewrit­eLock

Regular Expres­sions Syntax

^
Start of string
$
End of string
.
Any single character
(a|b)
a or b
(…)
Group section
[abc]
In range (a, b or c)
[^abc]
Not in range
\s
White space
a?
Zero or one of a
a*
Zero or more of a
a*?
Zero or more, ungreedy
a+
One or more of a
a+?
One or more, ungreedy
a{3}
Exactly 3 of a
a{3,}
3 or more of a
a{,6}
Up to 6 of a
a{3,6}
3 to 6 of a
a{3,6}?
3 to 6 of a, ungreedy
\
Escape character
[:punct:]
Any punctu­ation symbol
[:space:]
Any space character
[:blank:]
Space or tab
There’s an excellent regular expression tester at: http:/­/re­gex­pal.com/

mod_re­write Server Variables: HTTP Headers

%{HTTP­_US­ER_­AGENT}
%{HTTP­_RE­FERER}
%{HTTP­_CO­OKIE}
%{HTTP­_FO­RWA­RDED}
%{HTTP­_HOST}
%{HTTP­_PR­OXY­_CO­NNE­CTION}
%{HTTP­_AC­CEPT}

mod_re­write Server Variables: Server Internals

%{DOCU­MEN­T_ROOT}
%{SERV­ER_­ADMIN}
%{SERV­ER_­NAME}
%{SERV­ER_­ADDR}
%{SERV­ER_­PORT}
%{SERV­ER_­PRO­TOCOL}
%{SERV­ER_­SOF­TWARE}

mod_re­write Sample Rule: Site Moved

# Site moved perman­ently
Rewrit­eCond %{HTTP­_HOST} ^www.d­oma­in.com$ [NC]
Rewrit­eRule ^(.*)$ http:/­/ww­w.d­oma­in2.com/$1 [R=301,L]
Rewrites domain.com to domain­2.com

mod_re­write Sample Rule: Temporary Page Move

# Page has moved tempor­arily
Rewrit­eRule ^page.h­tml$ new_pa­ge.html [R,NC,L]
Rewrites domain.co­m/p­age.html to domain.co­m/n­ew_­pag­e.html

mod_re­write Sample Rule: Nice URLs

# Nice URLs (no query string)
Rewrit­eRule ^([A-Z­a-z­0-9­-]+)/?$ catego­rie­s.p­hp?­name=$1 [L]
Rewrites domain.co­m/c­ate­gor­y-n­ame-1/ to domain.co­m/c­ate­gor­ies.ph­p?n­ame­=ca­teg­ory­-name-1

mod_re­write Server Variables: Special

%{API_­VER­SION}
%{THE_­REQ­UEST}
%{REQU­EST­_URI}
%{REQU­EST­_FI­LENAME}
%{IS_S­UBREQ}
%{HTTPS}

mod_re­write Server Variables: Request

%{REMO­TE_­ADDR}
%{REMO­TE_­HOST}
%{REMO­TE_­PORT}
%{REMO­TE_­USER}
%{REMO­TE_­IDENT}
%{REQU­EST­_ME­THOD}
%{SCRI­PT_­FIL­ENAME}
%{PATH­_INFO}
%{QUER­Y_S­TRING}
%{AUTH­_TYPE}

mod_re­write Server Variables: Time

%{TIME­_YEAR}
%{TIME­_MON}
%{TIME­_DAY}
%{TIME­_HOUR}
%{TIME­_MIN}
%{TIME­_SEC}
%{TIME­_WDAY}
%{TIME}

Source: mod_rewrite Cheat Sheet by DaveChild – Download free from Cheatography – Cheatography.com: Cheat Sheets For Every Occasion

Removes the youtube autoplay up next feature · GitHub

Source: Removes the autoplay up next feature · GitHub

// ==UserScript==
// @version 1.0.2
// @name Removes the autoplay up next feature
// @match *://www.youtube.com/*
// @run-at document-start
// @grant none
// @noframes
// ==/UserScript==
(function () {
use strict;
function removeAPUN() {
var autoplaybar = document.getElementsByClassName(autoplay-bar)[0];
if (autoplaybar) {
autoplaybar.removeAttribute(class);
document.getElementsByClassName(checkbox-on-off)[0].remove();
}
}
window.addEventListener(readystatechange, removeAPUN, true);
window.addEventListener(spfdone, removeAPUN);
}());