Przeglądaj źródła

Fix anchor icon missing on origins with strict csp

simov 1 rok temu
rodzic
commit
6949ecdd8d
3 zmienionych plików z 17 dodań i 2 usunięć
  1. 14 0
      build/themes/fix-themes.js
  2. 1 0
      content/anchor.svg
  3. 2 2
      content/index.css

+ 14 - 0
build/themes/fix-themes.js

@@ -3,6 +3,20 @@ var fs = require('fs')
 var path = require('path')
 var themes = path.resolve(__dirname, '../../themes/')
 
+fs.writeFileSync(
+  path.resolve(themes, 'github.css'),
+  fs.readFileSync(path.resolve(themes, 'github.css'), 'utf8')
+    .replaceAll(/mask-image:url\(".*?"\)/g, 'mask-image:url("chrome-extension://__MSG_@@extension_id__/content/anchor.svg")'),
+  'utf8'
+)
+
+fs.writeFileSync(
+  path.resolve(themes, 'github-dark.css'),
+  fs.readFileSync(path.resolve(themes, 'github-dark.css'), 'utf8')
+    .replaceAll(/mask-image:url\(".*?"\)/g, 'mask-image:url("chrome-extension://__MSG_@@extension_id__/content/anchor.svg")'),
+  'utf8'
+)
+
 fs.writeFileSync(
   path.resolve(themes, 'mini.css'),
   fs.readFileSync(path.resolve(themes, 'mini.css'), 'utf8')

+ 1 - 0
content/anchor.svg

@@ -0,0 +1 @@
+<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>

+ 2 - 2
content/index.css

@@ -259,8 +259,8 @@ body._toc-right { padding-right: 300px !important; }
   content: ' ';
   display: inline-block;
   background-color: currentColor;
-  -webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
-  mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
+  -webkit-mask-image: url("chrome-extension://__MSG_@@extension_id__/content/anchor.svg");
+  mask-image: url("chrome-extension://__MSG_@@extension_id__/content/anchor.svg");
 }
 
 .markdown-theme h1 .octicon-link,