├── .gitignore
├── CHANGELOG.md
├── InjectJS Extension
├── Base.lproj
│ └── SafariExtensionViewController.xib
├── Info.plist
├── InjectJS_Extension.entitlements
├── SafariExtensionHandler.swift
├── SafariExtensionViewController.swift
├── ToolbarItemIcon.pdf
├── editor.html
├── editor
│ ├── CodeMirror
│ │ ├── addon
│ │ │ ├── active-line.js
│ │ │ ├── closebrackets.js
│ │ │ ├── comment.js
│ │ │ ├── fold
│ │ │ │ ├── brace-fold.js
│ │ │ │ ├── foldcode.js
│ │ │ │ ├── foldgutter.css
│ │ │ │ ├── foldgutter.js
│ │ │ │ └── indent-fold.js
│ │ │ ├── hint
│ │ │ │ ├── css-hint.js
│ │ │ │ ├── javascript-hint.js
│ │ │ │ ├── show-hint.css
│ │ │ │ └── show-hint.js
│ │ │ ├── matchbrackets.js
│ │ │ ├── placeholder.js
│ │ │ └── search.js
│ │ ├── codemirror.css
│ │ ├── codemirror.js
│ │ └── mode
│ │ │ ├── css.js
│ │ │ └── javascript.js
│ ├── editor.css
│ ├── editor.js
│ └── localize.js
└── script.js
├── InjectJS.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── IDEWorkspaceChecks.plist
├── InjectJS
├── AppDelegate.swift
├── Assets.xcassets
│ ├── AppIcon.appiconset
│ │ ├── 1024.png
│ │ ├── 128.png
│ │ ├── 16.png
│ │ ├── 256-1.png
│ │ ├── 256.png
│ │ ├── 32-1.png
│ │ ├── 32.png
│ │ ├── 512-1.png
│ │ ├── 512.png
│ │ ├── 64.png
│ │ └── Contents.json
│ └── Contents.json
├── Base.lproj
│ └── Main.storyboard
├── Info.plist
├── InjectJS.entitlements
└── ViewController.swift
├── LICENSE
├── README.md
└── etc
├── App Store Screenshot.png
├── InjectJS-demo.mp4
└── assets.sketch
/.gitignore:
--------------------------------------------------------------------------------
1 | xcuserdata/
2 | *.xcuserstate
3 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | ## v1.0
4 | - Forked from [Userscripts v1.5.0](https://github.com/quoid/userscripts/releases/tag/v1.5.0) & released under new name
5 |
6 | ## Prior Userscripts Changelog
7 |
8 | #### Userscripts v1.5.0 (2019-10-14)
9 | - Enable code folding in editor
10 | - Minor styling changes
11 |
12 | #### Userscripts v1.4.0 (2019-08-28)
13 | - A lot of code cleanup and refactoring
14 | - Improved the popover loading experience
15 | - Javascript is now saved to a .js file, rather than .json
16 |
17 | #### Userscripts v1.3.0 (2019-07-24)
18 | - Refactored WKWebView implementation to better support Catalina
19 | - View styling changes to prevent initial "white flash" before WKWebView loads
20 | - Minor CSS style updates
21 |
22 | #### Userscripts v1.2.0 (2019-07-02)
23 | - Fixed an issue that prevented script injection on websites with strict CSP
24 | - Disabled 3D touch within the editor, which was causing cursor issues
25 | - Styling updates
26 |
27 | #### Userscripts v1.1.0 (2019-06-13)
28 | - Added the ability for users to toggle the extension on/off
29 | - Updated the popover dimensions
30 | - Tabs are now transformed into spaces within the editor
31 | - Created a workaround so that the mouse cursor changes appropriately when hovering certain elements
32 | - Fixed a bug that allowed users to overwrite a saved script when no changes occurred
33 | - Fixed a bug that was showing a undefined "Last edited" date on first launch of the extension
34 |
35 | #### Userscripts v1.0.3 (2019-05-13)
36 |
37 | Initial release using [Safari App Extensions](https://developer.apple.com/documentation/safariservices/safari_app_extensions) format
38 |
39 | #### v1.0.0 (2018-12-01)
40 |
41 | Initial release using [Safari Extension JS](https://developer.apple.com/documentation/safariextensions) - depreciated as of 2019-01-01
--------------------------------------------------------------------------------
/InjectJS Extension/Base.lproj/SafariExtensionViewController.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
--------------------------------------------------------------------------------
/InjectJS Extension/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleDisplayName
8 | InjectJS
9 | CFBundleExecutable
10 | $(EXECUTABLE_NAME)
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSMinimumSystemVersion
24 | $(MACOSX_DEPLOYMENT_TARGET)
25 | NSExtension
26 |
27 | NSExtensionPointIdentifier
28 | com.apple.Safari.extension
29 | NSExtensionPrincipalClass
30 | $(PRODUCT_MODULE_NAME).SafariExtensionHandler
31 | SFSafariContentScript
32 |
33 |
34 | Script
35 | script.js
36 |
37 |
38 | SFSafariToolbarItem
39 |
40 | Action
41 | Popover
42 | Identifier
43 | Button
44 | Image
45 | ToolbarItemIcon.pdf
46 | Label
47 | InjectJS
48 |
49 | SFSafariWebsiteAccess
50 |
51 | Level
52 | All
53 |
54 |
55 | NSHumanReadableCopyright
56 | Copyright © 2020 Justin Wasack. All rights reserved.
57 | NSHumanReadableDescription
58 | Save and run javascript for the web pages you visit
59 |
60 |
61 |
--------------------------------------------------------------------------------
/InjectJS Extension/InjectJS_Extension.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.files.user-selected.read-only
8 |
9 | com.apple.security.network.client
10 |
11 |
12 |
13 |
--------------------------------------------------------------------------------
/InjectJS Extension/SafariExtensionHandler.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SafariExtensionHandler.swift
3 | // InjectJS Extension
4 | //
5 | // Created by Justin Wasack on 5/6/20.
6 | // Copyright © 2020 Justin Wasack. All rights reserved.
7 | //
8 |
9 | import SafariServices
10 | import WebKit
11 |
12 | class SafariExtensionHandler: SFSafariExtensionHandler {
13 |
14 | override func messageReceived(withName messageName: String, from page: SFSafariPage, userInfo: [String : Any]?) {
15 | if messageName == "REQUEST_SAVED_CODE" {
16 | if getSavedCode() != nil && UserDefaults.standard.bool(forKey: "toggleOff") != true {
17 | let code = getSavedCode()!.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
18 | page.dispatchMessageToScript(withName: "SEND_SAVED_CODE", userInfo: ["code": code])
19 | }
20 | }
21 | }
22 |
23 | override func toolbarItemClicked(in window: SFSafariWindow) {
24 | // This method will be called when your toolbar item is clicked.
25 | NSLog("The extension's toolbar item was clicked")
26 | }
27 |
28 | override func validateToolbarItem(in window: SFSafariWindow, validationHandler: @escaping ((Bool, String) -> Void)) {
29 | validationHandler(true, "")
30 | }
31 |
32 | override func popoverViewController() -> SFSafariExtensionViewController {
33 | return SafariExtensionViewController.shared
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/InjectJS Extension/SafariExtensionViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // SafariExtensionViewController.swift
3 | // InjectJS Extension
4 | //
5 | // Created by Justin Wasack on 5/6/20.
6 | // Copyright © 2020 Justin Wasack. All rights reserved.
7 | //
8 |
9 | import SafariServices
10 | import WebKit
11 |
12 | class SafariExtensionViewController: SFSafariExtensionViewController, WKScriptMessageHandler, WKNavigationDelegate {
13 |
14 | var webView: WKWebView!
15 |
16 | static let shared: SafariExtensionViewController = {
17 | let shared = SafariExtensionViewController()
18 | shared.preferredContentSize = NSSize(width:624, height:624)
19 | return shared
20 | }()
21 |
22 | func initWebView() {
23 | let parentHeight = SafariExtensionViewController.shared.preferredContentSize.height
24 | let parentWidth = SafariExtensionViewController.shared.preferredContentSize.width
25 | let webViewConfig = WKWebViewConfiguration()
26 | let bundleURL = Bundle.main.resourceURL!.absoluteURL
27 | let html = bundleURL.appendingPathComponent("editor.html")
28 | webViewConfig.preferences.setValue(true, forKey: "developerExtrasEnabled")
29 | webViewConfig.userContentController.add(self, name: "webViewReady")
30 | webViewConfig.userContentController.add(self, name: "setCursor")
31 | webViewConfig.userContentController.add(self, name: "saveCode")
32 | webViewConfig.userContentController.add(self, name: "setStatus")
33 | webViewConfig.userContentController.add(self, name: "setModificationDate")
34 | webViewConfig.userContentController.add(self, name: "getInfo")
35 | webViewConfig.userContentController.add(self, name: "downloadScript")
36 | webView = WKWebView(frame: CGRect(x: 0, y: 0, width: parentWidth, height: parentHeight), configuration: webViewConfig)
37 | webView.navigationDelegate = self
38 | webView.allowsLinkPreview = false
39 | webView.loadFileURL(html, allowingReadAccessTo:bundleURL)
40 | webView.alphaValue = 0.0;
41 | self.view.addSubview(webView)
42 | }
43 |
44 | override func viewDidLoad() {
45 | super.viewDidLoad()
46 | let backgroundColor = NSColor.init(red: (39/255.0), green: (42/255.0), blue: (46/255.0), alpha: 1.0)
47 | view.setValue(backgroundColor, forKey: "backgroundColor")
48 | if UserDefaults.standard.object(forKey: "toggleOff") == nil {
49 | UserDefaults.standard.set(false, forKey: "toggleOff")
50 | }
51 | initWebView()
52 | }
53 |
54 | func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
55 | let lang = Locale.current.languageCode!
56 | let ver = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
57 | let toggle = UserDefaults.standard.bool(forKey: "toggleOff")
58 | if var code = getSavedCode() {
59 | code = code.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
60 | webView.evaluateJavaScript("___userscripts.init('\(lang)', '\(ver)', '\(toggle)', '\(code)');", completionHandler: nil)
61 | } else {
62 | webView.evaluateJavaScript("___userscripts.init('\(lang)', '\(ver)', '\(toggle)');", completionHandler: nil)
63 | }
64 | }
65 |
66 | func saveCode(code:String) {
67 | let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
68 | let path = documentDirectory.appending("/userscript.js")
69 | let fileURL = URL(fileURLWithPath: path)
70 | let fileContent = code
71 | do {
72 | try fileContent.write(to: fileURL, atomically: false, encoding: .utf8)
73 | let escapedCode = code.addingPercentEncoding(withAllowedCharacters: .alphanumerics)!
74 | webView.evaluateJavaScript("___userscripts.saveSucceed('\(escapedCode)');", completionHandler: { (value, error) in
75 | guard error == nil else {return}
76 | let d = getModificationDate()
77 | DispatchQueue.main.asyncAfter(deadline: .now() + 1.25) {
78 | self.webView.evaluateJavaScript("___userscripts.setStatusText('\(d)', '\(true)');", completionHandler: nil)
79 | }
80 | })
81 | } catch {
82 | webView.evaluateJavaScript("___userscripts.saveFail();", completionHandler: nil)
83 | }
84 | }
85 |
86 | func userContentController(_ userContentController: WKUserContentController, didReceive message: WKScriptMessage) {
87 | if message.name == "webViewReady" {
88 | if getSavedCode() != nil && UserDefaults.standard.bool(forKey: "toggleOff") == false {
89 | let d = getModificationDate()
90 | self.webView.evaluateJavaScript("___userscripts.setStatusText('\(d)', '\(true)');", completionHandler: nil)
91 | }
92 | NSAnimationContext.runAnimationGroup({_ in
93 | NSAnimationContext.current.duration = 0.35
94 | webView.animator().alphaValue = 1.0
95 | })
96 | }
97 | if message.name == "setCursor" {
98 | let cursor = message.body as! String
99 | switch cursor {
100 | case "auto", "default":
101 | NSCursor.arrow.set()
102 | case "pointer":
103 | NSCursor.pointingHand.set()
104 | case "text":
105 | NSCursor.iBeam.set()
106 | default:
107 | break
108 | }
109 | }
110 | if message.name == "saveCode" {
111 | let code = message.body as! String
112 | saveCode(code: code)
113 | }
114 | if message.name == "setStatus" {
115 | let toggleStatus = message.body as! Bool
116 | UserDefaults.standard.set(toggleStatus, forKey: "toggleOff")
117 | }
118 | if message.name == "setModificationDate" {
119 | let d = getModificationDate()
120 | webView.evaluateJavaScript("___userscripts.setStatusText('\(d)', '\(true)');", completionHandler: nil)
121 | }
122 | if message.name == "getInfo" {
123 | openExtensionHomepage()
124 | dismissPopover()
125 | }
126 | if message.name == "downloadScript" {
127 | downloadScript()
128 | }
129 | }
130 | }
131 |
132 | func getModificationDate() -> String {
133 | let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
134 | let path = documentDirectory.appending("/userscript.js")
135 | let dateFormatter = DateFormatter()
136 | dateFormatter.dateStyle = .medium
137 | dateFormatter.timeStyle = .short
138 | do {
139 | let date = try FileManager.default.attributesOfItem(atPath: path)[.modificationDate] as! Date
140 | return dateFormatter.string(from: date)
141 | } catch {
142 | return "error getting date"
143 | }
144 | }
145 |
146 | func getSavedCode() -> String? {
147 | let fileManager = FileManager.default
148 | let documentDirectory = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0] as String
149 | let path = documentDirectory.appending("/userscript.js")
150 | let fileURL = URL(fileURLWithPath: path)
151 | var savedCode:String?
152 | if fileManager.fileExists(atPath: path) {
153 | do {
154 | savedCode = try String(contentsOf: fileURL, encoding: .utf8)
155 | } catch {
156 | print(error)
157 | }
158 | }
159 | return savedCode
160 | }
161 |
162 | func openExtensionHomepage() {
163 | guard let url = URL(string: "https://github.com/quoid/userscripts") else { return }
164 | SFSafariApplication.getActiveWindow { (window) in
165 | window?.openTab(with: url, makeActiveIfPossible: true) { (tab) in
166 | //although it is stated in the documentation that the completion handler is optional, that is untrue
167 | }
168 | }
169 | }
170 |
171 | func downloadScript() {
172 | guard let code = getSavedCode() else {return}
173 | SFSafariApplication.getActiveWindow { (window) in
174 | window?.getActiveTab { (tab) in
175 | tab?.getActivePage { (page) in
176 | page?.dispatchMessageToScript(withName: "DOWNLOAD_SCRIPT", userInfo: ["code": code])
177 | }
178 | }
179 | }
180 | }
181 |
--------------------------------------------------------------------------------
/InjectJS Extension/ToolbarItemIcon.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS Extension/ToolbarItemIcon.pdf
--------------------------------------------------------------------------------
/InjectJS Extension/editor.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 | InjectJS ...
27 |
28 |
33 |
39 |
45 |
46 |
47 |
48 |
49 |
54 |
55 |
56 |
57 |
58 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/active-line.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 | var WRAP_CLASS = "CodeMirror-activeline";
14 | var BACK_CLASS = "CodeMirror-activeline-background";
15 | var GUTT_CLASS = "CodeMirror-activeline-gutter";
16 |
17 | CodeMirror.defineOption("styleActiveLine", false, function(cm, val, old) {
18 | var prev = old == CodeMirror.Init ? false : old;
19 | if (val == prev) return
20 | if (prev) {
21 | cm.off("beforeSelectionChange", selectionChange);
22 | clearActiveLines(cm);
23 | delete cm.state.activeLines;
24 | }
25 | if (val) {
26 | cm.state.activeLines = [];
27 | updateActiveLines(cm, cm.listSelections());
28 | cm.on("beforeSelectionChange", selectionChange);
29 | }
30 | });
31 |
32 | function clearActiveLines(cm) {
33 | for (var i = 0; i < cm.state.activeLines.length; i++) {
34 | cm.removeLineClass(cm.state.activeLines[i], "wrap", WRAP_CLASS);
35 | cm.removeLineClass(cm.state.activeLines[i], "background", BACK_CLASS);
36 | cm.removeLineClass(cm.state.activeLines[i], "gutter", GUTT_CLASS);
37 | }
38 | }
39 |
40 | function sameArray(a, b) {
41 | if (a.length != b.length) return false;
42 | for (var i = 0; i < a.length; i++)
43 | if (a[i] != b[i]) return false;
44 | return true;
45 | }
46 |
47 | function updateActiveLines(cm, ranges) {
48 | var active = [];
49 | for (var i = 0; i < ranges.length; i++) {
50 | var range = ranges[i];
51 | var option = cm.getOption("styleActiveLine");
52 | if (typeof option == "object" && option.nonEmpty ? range.anchor.line != range.head.line : !range.empty())
53 | continue
54 | var line = cm.getLineHandleVisualStart(range.head.line);
55 | if (active[active.length - 1] != line) active.push(line);
56 | }
57 | if (sameArray(cm.state.activeLines, active)) return;
58 | cm.operation(function() {
59 | clearActiveLines(cm);
60 | for (var i = 0; i < active.length; i++) {
61 | cm.addLineClass(active[i], "wrap", WRAP_CLASS);
62 | cm.addLineClass(active[i], "background", BACK_CLASS);
63 | cm.addLineClass(active[i], "gutter", GUTT_CLASS);
64 | }
65 | cm.state.activeLines = active;
66 | });
67 | }
68 |
69 | function selectionChange(cm, sel) {
70 | updateActiveLines(cm, sel.ranges);
71 | }
72 | });
73 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/closebrackets.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | var defaults = {
13 | pairs: "()[]{}''\"\"",
14 | triples: "",
15 | explode: "[]{}"
16 | };
17 |
18 | var Pos = CodeMirror.Pos;
19 |
20 | CodeMirror.defineOption("autoCloseBrackets", false, function(cm, val, old) {
21 | if (old && old != CodeMirror.Init) {
22 | cm.removeKeyMap(keyMap);
23 | cm.state.closeBrackets = null;
24 | }
25 | if (val) {
26 | ensureBound(getOption(val, "pairs"))
27 | cm.state.closeBrackets = val;
28 | cm.addKeyMap(keyMap);
29 | }
30 | });
31 |
32 | function getOption(conf, name) {
33 | if (name == "pairs" && typeof conf == "string") return conf;
34 | if (typeof conf == "object" && conf[name] != null) return conf[name];
35 | return defaults[name];
36 | }
37 |
38 | var keyMap = {Backspace: handleBackspace, Enter: handleEnter};
39 | function ensureBound(chars) {
40 | for (var i = 0; i < chars.length; i++) {
41 | var ch = chars.charAt(i), key = "'" + ch + "'"
42 | if (!keyMap[key]) keyMap[key] = handler(ch)
43 | }
44 | }
45 | ensureBound(defaults.pairs + "`")
46 |
47 | function handler(ch) {
48 | return function(cm) { return handleChar(cm, ch); };
49 | }
50 |
51 | function getConfig(cm) {
52 | var deflt = cm.state.closeBrackets;
53 | if (!deflt || deflt.override) return deflt;
54 | var mode = cm.getModeAt(cm.getCursor());
55 | return mode.closeBrackets || deflt;
56 | }
57 |
58 | function handleBackspace(cm) {
59 | var conf = getConfig(cm);
60 | if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
61 |
62 | var pairs = getOption(conf, "pairs");
63 | var ranges = cm.listSelections();
64 | for (var i = 0; i < ranges.length; i++) {
65 | if (!ranges[i].empty()) return CodeMirror.Pass;
66 | var around = charsAround(cm, ranges[i].head);
67 | if (!around || pairs.indexOf(around) % 2 != 0) return CodeMirror.Pass;
68 | }
69 | for (var i = ranges.length - 1; i >= 0; i--) {
70 | var cur = ranges[i].head;
71 | cm.replaceRange("", Pos(cur.line, cur.ch - 1), Pos(cur.line, cur.ch + 1), "+delete");
72 | }
73 | }
74 |
75 | function handleEnter(cm) {
76 | var conf = getConfig(cm);
77 | var explode = conf && getOption(conf, "explode");
78 | if (!explode || cm.getOption("disableInput")) return CodeMirror.Pass;
79 |
80 | var ranges = cm.listSelections();
81 | for (var i = 0; i < ranges.length; i++) {
82 | if (!ranges[i].empty()) return CodeMirror.Pass;
83 | var around = charsAround(cm, ranges[i].head);
84 | if (!around || explode.indexOf(around) % 2 != 0) return CodeMirror.Pass;
85 | }
86 | cm.operation(function() {
87 | var linesep = cm.lineSeparator() || "\n";
88 | cm.replaceSelection(linesep + linesep, null);
89 | cm.execCommand("goCharLeft");
90 | ranges = cm.listSelections();
91 | for (var i = 0; i < ranges.length; i++) {
92 | var line = ranges[i].head.line;
93 | cm.indentLine(line, null, true);
94 | cm.indentLine(line + 1, null, true);
95 | }
96 | });
97 | }
98 |
99 | function contractSelection(sel) {
100 | var inverted = CodeMirror.cmpPos(sel.anchor, sel.head) > 0;
101 | return {anchor: new Pos(sel.anchor.line, sel.anchor.ch + (inverted ? -1 : 1)),
102 | head: new Pos(sel.head.line, sel.head.ch + (inverted ? 1 : -1))};
103 | }
104 |
105 | function handleChar(cm, ch) {
106 | var conf = getConfig(cm);
107 | if (!conf || cm.getOption("disableInput")) return CodeMirror.Pass;
108 |
109 | var pairs = getOption(conf, "pairs");
110 | var pos = pairs.indexOf(ch);
111 | if (pos == -1) return CodeMirror.Pass;
112 | var triples = getOption(conf, "triples");
113 |
114 | var identical = pairs.charAt(pos + 1) == ch;
115 | var ranges = cm.listSelections();
116 | var opening = pos % 2 == 0;
117 |
118 | var type;
119 | for (var i = 0; i < ranges.length; i++) {
120 | var range = ranges[i], cur = range.head, curType;
121 | var next = cm.getRange(cur, Pos(cur.line, cur.ch + 1));
122 | if (opening && !range.empty()) {
123 | curType = "surround";
124 | } else if ((identical || !opening) && next == ch) {
125 | if (identical && stringStartsAfter(cm, cur))
126 | curType = "both";
127 | else if (triples.indexOf(ch) >= 0 && cm.getRange(cur, Pos(cur.line, cur.ch + 3)) == ch + ch + ch)
128 | curType = "skipThree";
129 | else
130 | curType = "skip";
131 | } else if (identical && cur.ch > 1 && triples.indexOf(ch) >= 0 &&
132 | cm.getRange(Pos(cur.line, cur.ch - 2), cur) == ch + ch) {
133 | if (cur.ch > 2 && /\bstring/.test(cm.getTokenTypeAt(Pos(cur.line, cur.ch - 2)))) return CodeMirror.Pass;
134 | curType = "addFour";
135 | } else if (identical) {
136 | var prev = cur.ch == 0 ? " " : cm.getRange(Pos(cur.line, cur.ch - 1), cur)
137 | if (!CodeMirror.isWordChar(next) && prev != ch && !CodeMirror.isWordChar(prev)) curType = "both";
138 | else return CodeMirror.Pass;
139 | } else if (opening) {
140 | curType = "both";
141 | } else {
142 | return CodeMirror.Pass;
143 | }
144 | if (!type) type = curType;
145 | else if (type != curType) return CodeMirror.Pass;
146 | }
147 |
148 | var left = pos % 2 ? pairs.charAt(pos - 1) : ch;
149 | var right = pos % 2 ? ch : pairs.charAt(pos + 1);
150 | cm.operation(function() {
151 | if (type == "skip") {
152 | cm.execCommand("goCharRight");
153 | } else if (type == "skipThree") {
154 | for (var i = 0; i < 3; i++)
155 | cm.execCommand("goCharRight");
156 | } else if (type == "surround") {
157 | var sels = cm.getSelections();
158 | for (var i = 0; i < sels.length; i++)
159 | sels[i] = left + sels[i] + right;
160 | cm.replaceSelections(sels, "around");
161 | sels = cm.listSelections().slice();
162 | for (var i = 0; i < sels.length; i++)
163 | sels[i] = contractSelection(sels[i]);
164 | cm.setSelections(sels);
165 | } else if (type == "both") {
166 | cm.replaceSelection(left + right, null);
167 | cm.triggerElectric(left + right);
168 | cm.execCommand("goCharLeft");
169 | } else if (type == "addFour") {
170 | cm.replaceSelection(left + left + left + left, "before");
171 | cm.execCommand("goCharRight");
172 | }
173 | });
174 | }
175 |
176 | function charsAround(cm, pos) {
177 | var str = cm.getRange(Pos(pos.line, pos.ch - 1),
178 | Pos(pos.line, pos.ch + 1));
179 | return str.length == 2 ? str : null;
180 | }
181 |
182 | function stringStartsAfter(cm, pos) {
183 | var token = cm.getTokenAt(Pos(pos.line, pos.ch + 1))
184 | return /\bstring/.test(token.type) && token.start == pos.ch &&
185 | (pos.ch == 0 || !/\bstring/.test(cm.getTokenTypeAt(pos)))
186 | }
187 | });
188 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/comment.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var noOptions = {};
15 | var nonWS = /[^\s\u00a0]/;
16 | var Pos = CodeMirror.Pos;
17 |
18 | function firstNonWS(str) {
19 | var found = str.search(nonWS);
20 | return found == -1 ? 0 : found;
21 | }
22 |
23 | CodeMirror.commands.toggleComment = function(cm) {
24 | cm.toggleComment();
25 | };
26 |
27 | CodeMirror.defineExtension("toggleComment", function(options) {
28 | if (!options) options = noOptions;
29 | var cm = this;
30 | var minLine = Infinity, ranges = this.listSelections(), mode = null;
31 | for (var i = ranges.length - 1; i >= 0; i--) {
32 | var from = ranges[i].from(), to = ranges[i].to();
33 | if (from.line >= minLine) continue;
34 | if (to.line >= minLine) to = Pos(minLine, 0);
35 | minLine = from.line;
36 | if (mode == null) {
37 | if (cm.uncomment(from, to, options)) mode = "un";
38 | else { cm.lineComment(from, to, options); mode = "line"; }
39 | } else if (mode == "un") {
40 | cm.uncomment(from, to, options);
41 | } else {
42 | cm.lineComment(from, to, options);
43 | }
44 | }
45 | });
46 |
47 | // Rough heuristic to try and detect lines that are part of multi-line string
48 | function probablyInsideString(cm, pos, line) {
49 | return /\bstring\b/.test(cm.getTokenTypeAt(Pos(pos.line, 0))) && !/^[\'\"\`]/.test(line)
50 | }
51 |
52 | function getMode(cm, pos) {
53 | var mode = cm.getMode()
54 | return mode.useInnerComments === false || !mode.innerMode ? mode : cm.getModeAt(pos)
55 | }
56 |
57 | CodeMirror.defineExtension("lineComment", function(from, to, options) {
58 | if (!options) options = noOptions;
59 | var self = this, mode = getMode(self, from);
60 | var firstLine = self.getLine(from.line);
61 | if (firstLine == null || probablyInsideString(self, from, firstLine)) return;
62 |
63 | var commentString = options.lineComment || mode.lineComment;
64 | if (!commentString) {
65 | if (options.blockCommentStart || mode.blockCommentStart) {
66 | options.fullLines = true;
67 | self.blockComment(from, to, options);
68 | }
69 | return;
70 | }
71 |
72 | var end = Math.min(to.ch != 0 || to.line == from.line ? to.line + 1 : to.line, self.lastLine() + 1);
73 | var pad = options.padding == null ? " " : options.padding;
74 | var blankLines = options.commentBlankLines || from.line == to.line;
75 |
76 | self.operation(function() {
77 | if (options.indent) {
78 | var baseString = null;
79 | for (var i = from.line; i < end; ++i) {
80 | var line = self.getLine(i);
81 | var whitespace = line.slice(0, firstNonWS(line));
82 | if (baseString == null || baseString.length > whitespace.length) {
83 | baseString = whitespace;
84 | }
85 | }
86 | for (var i = from.line; i < end; ++i) {
87 | var line = self.getLine(i), cut = baseString.length;
88 | if (!blankLines && !nonWS.test(line)) continue;
89 | if (line.slice(0, cut) != baseString) cut = firstNonWS(line);
90 | self.replaceRange(baseString + commentString + pad, Pos(i, 0), Pos(i, cut));
91 | }
92 | } else {
93 | for (var i = from.line; i < end; ++i) {
94 | if (blankLines || nonWS.test(self.getLine(i)))
95 | self.replaceRange(commentString + pad, Pos(i, 0));
96 | }
97 | }
98 | });
99 | });
100 |
101 | CodeMirror.defineExtension("blockComment", function(from, to, options) {
102 | if (!options) options = noOptions;
103 | var self = this, mode = getMode(self, from);
104 | var startString = options.blockCommentStart || mode.blockCommentStart;
105 | var endString = options.blockCommentEnd || mode.blockCommentEnd;
106 | if (!startString || !endString) {
107 | if ((options.lineComment || mode.lineComment) && options.fullLines != false)
108 | self.lineComment(from, to, options);
109 | return;
110 | }
111 | if (/\bcomment\b/.test(self.getTokenTypeAt(Pos(from.line, 0)))) return
112 |
113 | var end = Math.min(to.line, self.lastLine());
114 | if (end != from.line && to.ch == 0 && nonWS.test(self.getLine(end))) --end;
115 |
116 | var pad = options.padding == null ? " " : options.padding;
117 | if (from.line > end) return;
118 |
119 | self.operation(function() {
120 | if (options.fullLines != false) {
121 | var lastLineHasText = nonWS.test(self.getLine(end));
122 | self.replaceRange(pad + endString, Pos(end));
123 | self.replaceRange(startString + pad, Pos(from.line, 0));
124 | var lead = options.blockCommentLead || mode.blockCommentLead;
125 | if (lead != null) for (var i = from.line + 1; i <= end; ++i)
126 | if (i != end || lastLineHasText)
127 | self.replaceRange(lead + pad, Pos(i, 0));
128 | } else {
129 | self.replaceRange(endString, to);
130 | self.replaceRange(startString, from);
131 | }
132 | });
133 | });
134 |
135 | CodeMirror.defineExtension("uncomment", function(from, to, options) {
136 | if (!options) options = noOptions;
137 | var self = this, mode = getMode(self, from);
138 | var end = Math.min(to.ch != 0 || to.line == from.line ? to.line : to.line - 1, self.lastLine()), start = Math.min(from.line, end);
139 |
140 | // Try finding line comments
141 | var lineString = options.lineComment || mode.lineComment, lines = [];
142 | var pad = options.padding == null ? " " : options.padding, didSomething;
143 | lineComment: {
144 | if (!lineString) break lineComment;
145 | for (var i = start; i <= end; ++i) {
146 | var line = self.getLine(i);
147 | var found = line.indexOf(lineString);
148 | if (found > -1 && !/comment/.test(self.getTokenTypeAt(Pos(i, found + 1)))) found = -1;
149 | if (found == -1 && nonWS.test(line)) break lineComment;
150 | if (found > -1 && nonWS.test(line.slice(0, found))) break lineComment;
151 | lines.push(line);
152 | }
153 | self.operation(function() {
154 | for (var i = start; i <= end; ++i) {
155 | var line = lines[i - start];
156 | var pos = line.indexOf(lineString), endPos = pos + lineString.length;
157 | if (pos < 0) continue;
158 | if (line.slice(endPos, endPos + pad.length) == pad) endPos += pad.length;
159 | didSomething = true;
160 | self.replaceRange("", Pos(i, pos), Pos(i, endPos));
161 | }
162 | });
163 | if (didSomething) return true;
164 | }
165 |
166 | // Try block comments
167 | var startString = options.blockCommentStart || mode.blockCommentStart;
168 | var endString = options.blockCommentEnd || mode.blockCommentEnd;
169 | if (!startString || !endString) return false;
170 | var lead = options.blockCommentLead || mode.blockCommentLead;
171 | var startLine = self.getLine(start), open = startLine.indexOf(startString)
172 | if (open == -1) return false
173 | var endLine = end == start ? startLine : self.getLine(end)
174 | var close = endLine.indexOf(endString, end == start ? open + startString.length : 0);
175 | var insideStart = Pos(start, open + 1), insideEnd = Pos(end, close + 1)
176 | if (close == -1 ||
177 | !/comment/.test(self.getTokenTypeAt(insideStart)) ||
178 | !/comment/.test(self.getTokenTypeAt(insideEnd)) ||
179 | self.getRange(insideStart, insideEnd, "\n").indexOf(endString) > -1)
180 | return false;
181 |
182 | // Avoid killing block comments completely outside the selection.
183 | // Positions of the last startString before the start of the selection, and the first endString after it.
184 | var lastStart = startLine.lastIndexOf(startString, from.ch);
185 | var firstEnd = lastStart == -1 ? -1 : startLine.slice(0, from.ch).indexOf(endString, lastStart + startString.length);
186 | if (lastStart != -1 && firstEnd != -1 && firstEnd + endString.length != from.ch) return false;
187 | // Positions of the first endString after the end of the selection, and the last startString before it.
188 | firstEnd = endLine.indexOf(endString, to.ch);
189 | var almostLastStart = endLine.slice(to.ch).lastIndexOf(startString, firstEnd - to.ch);
190 | lastStart = (firstEnd == -1 || almostLastStart == -1) ? -1 : to.ch + almostLastStart;
191 | if (firstEnd != -1 && lastStart != -1 && lastStart != to.ch) return false;
192 |
193 | self.operation(function() {
194 | self.replaceRange("", Pos(end, close - (pad && endLine.slice(close - pad.length, close) == pad ? pad.length : 0)),
195 | Pos(end, close + endString.length));
196 | var openEnd = open + startString.length;
197 | if (pad && startLine.slice(openEnd, openEnd + pad.length) == pad) openEnd += pad.length;
198 | self.replaceRange("", Pos(start, open), Pos(start, openEnd));
199 | if (lead) for (var i = start + 1; i <= end; ++i) {
200 | var line = self.getLine(i), found = line.indexOf(lead);
201 | if (found == -1 || nonWS.test(line.slice(0, found))) continue;
202 | var foundEnd = found + lead.length;
203 | if (pad && line.slice(foundEnd, foundEnd + pad.length) == pad) foundEnd += pad.length;
204 | self.replaceRange("", Pos(i, found), Pos(i, foundEnd));
205 | }
206 | });
207 | return true;
208 | });
209 | });
210 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/fold/brace-fold.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.registerHelper("fold", "brace", function(cm, start) {
15 | var line = start.line, lineText = cm.getLine(line);
16 | var tokenType;
17 |
18 | function findOpening(openCh) {
19 | for (var at = start.ch, pass = 0;;) {
20 | var found = at <= 0 ? -1 : lineText.lastIndexOf(openCh, at - 1);
21 | if (found == -1) {
22 | if (pass == 1) break;
23 | pass = 1;
24 | at = lineText.length;
25 | continue;
26 | }
27 | if (pass == 1 && found < start.ch) break;
28 | tokenType = cm.getTokenTypeAt(CodeMirror.Pos(line, found + 1));
29 | if (!/^(comment|string)/.test(tokenType)) return found + 1;
30 | at = found - 1;
31 | }
32 | }
33 |
34 | var startToken = "{", endToken = "}", startCh = findOpening("{");
35 | if (startCh == null) {
36 | startToken = "[", endToken = "]";
37 | startCh = findOpening("[");
38 | }
39 |
40 | if (startCh == null) return;
41 | var count = 1, lastLine = cm.lastLine(), end, endCh;
42 | outer: for (var i = line; i <= lastLine; ++i) {
43 | var text = cm.getLine(i), pos = i == line ? startCh : 0;
44 | for (;;) {
45 | var nextOpen = text.indexOf(startToken, pos), nextClose = text.indexOf(endToken, pos);
46 | if (nextOpen < 0) nextOpen = text.length;
47 | if (nextClose < 0) nextClose = text.length;
48 | pos = Math.min(nextOpen, nextClose);
49 | if (pos == text.length) break;
50 | if (cm.getTokenTypeAt(CodeMirror.Pos(i, pos + 1)) == tokenType) {
51 | if (pos == nextOpen) ++count;
52 | else if (!--count) { end = i; endCh = pos; break outer; }
53 | }
54 | ++pos;
55 | }
56 | }
57 | if (end == null || line == end) return;
58 | return {from: CodeMirror.Pos(line, startCh),
59 | to: CodeMirror.Pos(end, endCh)};
60 | });
61 |
62 | CodeMirror.registerHelper("fold", "import", function(cm, start) {
63 | function hasImport(line) {
64 | if (line < cm.firstLine() || line > cm.lastLine()) return null;
65 | var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
66 | if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
67 | if (start.type != "keyword" || start.string != "import") return null;
68 | // Now find closing semicolon, return its position
69 | for (var i = line, e = Math.min(cm.lastLine(), line + 10); i <= e; ++i) {
70 | var text = cm.getLine(i), semi = text.indexOf(";");
71 | if (semi != -1) return {startCh: start.end, end: CodeMirror.Pos(i, semi)};
72 | }
73 | }
74 |
75 | var startLine = start.line, has = hasImport(startLine), prev;
76 | if (!has || hasImport(startLine - 1) || ((prev = hasImport(startLine - 2)) && prev.end.line == startLine - 1))
77 | return null;
78 | for (var end = has.end;;) {
79 | var next = hasImport(end.line + 1);
80 | if (next == null) break;
81 | end = next.end;
82 | }
83 | return {from: cm.clipPos(CodeMirror.Pos(startLine, has.startCh + 1)), to: end};
84 | });
85 |
86 | CodeMirror.registerHelper("fold", "include", function(cm, start) {
87 | function hasInclude(line) {
88 | if (line < cm.firstLine() || line > cm.lastLine()) return null;
89 | var start = cm.getTokenAt(CodeMirror.Pos(line, 1));
90 | if (!/\S/.test(start.string)) start = cm.getTokenAt(CodeMirror.Pos(line, start.end + 1));
91 | if (start.type == "meta" && start.string.slice(0, 8) == "#include") return start.start + 8;
92 | }
93 |
94 | var startLine = start.line, has = hasInclude(startLine);
95 | if (has == null || hasInclude(startLine - 1) != null) return null;
96 | for (var end = startLine;;) {
97 | var next = hasInclude(end + 1);
98 | if (next == null) break;
99 | ++end;
100 | }
101 | return {from: CodeMirror.Pos(startLine, has + 1),
102 | to: cm.clipPos(CodeMirror.Pos(end))};
103 | });
104 |
105 | });
106 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/fold/foldcode.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | function doFold(cm, pos, options, force) {
15 | if (options && options.call) {
16 | var finder = options;
17 | options = null;
18 | } else {
19 | var finder = getOption(cm, options, "rangeFinder");
20 | }
21 | if (typeof pos == "number") pos = CodeMirror.Pos(pos, 0);
22 | var minSize = getOption(cm, options, "minFoldSize");
23 |
24 | function getRange(allowFolded) {
25 | var range = finder(cm, pos);
26 | if (!range || range.to.line - range.from.line < minSize) return null;
27 | var marks = cm.findMarksAt(range.from);
28 | for (var i = 0; i < marks.length; ++i) {
29 | if (marks[i].__isFold && force !== "fold") {
30 | if (!allowFolded) return null;
31 | range.cleared = true;
32 | marks[i].clear();
33 | }
34 | }
35 | return range;
36 | }
37 |
38 | var range = getRange(true);
39 | if (getOption(cm, options, "scanUp")) while (!range && pos.line > cm.firstLine()) {
40 | pos = CodeMirror.Pos(pos.line - 1, 0);
41 | range = getRange(false);
42 | }
43 | if (!range || range.cleared || force === "unfold") return;
44 |
45 | var myWidget = makeWidget(cm, options);
46 | CodeMirror.on(myWidget, "mousedown", function(e) {
47 | myRange.clear();
48 | CodeMirror.e_preventDefault(e);
49 | });
50 | var myRange = cm.markText(range.from, range.to, {
51 | replacedWith: myWidget,
52 | clearOnEnter: getOption(cm, options, "clearOnEnter"),
53 | __isFold: true
54 | });
55 | myRange.on("clear", function(from, to) {
56 | CodeMirror.signal(cm, "unfold", cm, from, to);
57 | });
58 | CodeMirror.signal(cm, "fold", cm, range.from, range.to);
59 | }
60 |
61 | function makeWidget(cm, options) {
62 | var widget = getOption(cm, options, "widget");
63 | if (typeof widget == "string") {
64 | var text = document.createTextNode(widget);
65 | widget = document.createElement("span");
66 | widget.appendChild(text);
67 | widget.className = "CodeMirror-foldmarker";
68 | } else if (widget) {
69 | widget = widget.cloneNode(true)
70 | }
71 | return widget;
72 | }
73 |
74 | // Clumsy backwards-compatible interface
75 | CodeMirror.newFoldFunction = function(rangeFinder, widget) {
76 | return function(cm, pos) { doFold(cm, pos, {rangeFinder: rangeFinder, widget: widget}); };
77 | };
78 |
79 | // New-style interface
80 | CodeMirror.defineExtension("foldCode", function(pos, options, force) {
81 | doFold(this, pos, options, force);
82 | });
83 |
84 | CodeMirror.defineExtension("isFolded", function(pos) {
85 | var marks = this.findMarksAt(pos);
86 | for (var i = 0; i < marks.length; ++i)
87 | if (marks[i].__isFold) return true;
88 | });
89 |
90 | CodeMirror.commands.toggleFold = function(cm) {
91 | cm.foldCode(cm.getCursor());
92 | };
93 | CodeMirror.commands.fold = function(cm) {
94 | cm.foldCode(cm.getCursor(), null, "fold");
95 | };
96 | CodeMirror.commands.unfold = function(cm) {
97 | cm.foldCode(cm.getCursor(), null, "unfold");
98 | };
99 | CodeMirror.commands.foldAll = function(cm) {
100 | cm.operation(function() {
101 | for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
102 | cm.foldCode(CodeMirror.Pos(i, 0), null, "fold");
103 | });
104 | };
105 | CodeMirror.commands.unfoldAll = function(cm) {
106 | cm.operation(function() {
107 | for (var i = cm.firstLine(), e = cm.lastLine(); i <= e; i++)
108 | cm.foldCode(CodeMirror.Pos(i, 0), null, "unfold");
109 | });
110 | };
111 |
112 | CodeMirror.registerHelper("fold", "combine", function() {
113 | var funcs = Array.prototype.slice.call(arguments, 0);
114 | return function(cm, start) {
115 | for (var i = 0; i < funcs.length; ++i) {
116 | var found = funcs[i](cm, start);
117 | if (found) return found;
118 | }
119 | };
120 | });
121 |
122 | CodeMirror.registerHelper("fold", "auto", function(cm, start) {
123 | var helpers = cm.getHelpers(start, "fold");
124 | for (var i = 0; i < helpers.length; i++) {
125 | var cur = helpers[i](cm, start);
126 | if (cur) return cur;
127 | }
128 | });
129 |
130 | var defaultOptions = {
131 | rangeFinder: CodeMirror.fold.auto,
132 | widget: "\u2194",
133 | minFoldSize: 0,
134 | scanUp: false,
135 | clearOnEnter: true
136 | };
137 |
138 | CodeMirror.defineOption("foldOptions", null);
139 |
140 | function getOption(cm, options, name) {
141 | if (options && options[name] !== undefined)
142 | return options[name];
143 | var editorOptions = cm.options.foldOptions;
144 | if (editorOptions && editorOptions[name] !== undefined)
145 | return editorOptions[name];
146 | return defaultOptions[name];
147 | }
148 |
149 | CodeMirror.defineExtension("foldOption", function(options, name) {
150 | return getOption(this, options, name);
151 | });
152 | });
153 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/fold/foldgutter.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-foldmarker {
2 | color: blue;
3 | text-shadow: #b9f 1px 1px 2px, #b9f -1px -1px 2px, #b9f 1px -1px 2px, #b9f -1px 1px 2px;
4 | font-family: arial;
5 | line-height: .3;
6 | cursor: pointer;
7 | }
8 | .CodeMirror-foldgutter {
9 | width: .7em;
10 | }
11 | .CodeMirror-foldgutter-open,
12 | .CodeMirror-foldgutter-folded {
13 | cursor: pointer;
14 | }
15 | .CodeMirror-foldgutter-open:after {
16 | content: "\25BE";
17 | }
18 | .CodeMirror-foldgutter-folded:after {
19 | content: "\25B8";
20 | }
21 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/fold/foldgutter.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("./foldcode"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "./foldcode"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | CodeMirror.defineOption("foldGutter", false, function(cm, val, old) {
15 | if (old && old != CodeMirror.Init) {
16 | cm.clearGutter(cm.state.foldGutter.options.gutter);
17 | cm.state.foldGutter = null;
18 | cm.off("gutterClick", onGutterClick);
19 | cm.off("changes", onChange);
20 | cm.off("viewportChange", onViewportChange);
21 | cm.off("fold", onFold);
22 | cm.off("unfold", onFold);
23 | cm.off("swapDoc", onChange);
24 | }
25 | if (val) {
26 | cm.state.foldGutter = new State(parseOptions(val));
27 | updateInViewport(cm);
28 | cm.on("gutterClick", onGutterClick);
29 | cm.on("changes", onChange);
30 | cm.on("viewportChange", onViewportChange);
31 | cm.on("fold", onFold);
32 | cm.on("unfold", onFold);
33 | cm.on("swapDoc", onChange);
34 | }
35 | });
36 |
37 | var Pos = CodeMirror.Pos;
38 |
39 | function State(options) {
40 | this.options = options;
41 | this.from = this.to = 0;
42 | }
43 |
44 | function parseOptions(opts) {
45 | if (opts === true) opts = {};
46 | if (opts.gutter == null) opts.gutter = "CodeMirror-foldgutter";
47 | if (opts.indicatorOpen == null) opts.indicatorOpen = "CodeMirror-foldgutter-open";
48 | if (opts.indicatorFolded == null) opts.indicatorFolded = "CodeMirror-foldgutter-folded";
49 | return opts;
50 | }
51 |
52 | function isFolded(cm, line) {
53 | var marks = cm.findMarks(Pos(line, 0), Pos(line + 1, 0));
54 | for (var i = 0; i < marks.length; ++i) {
55 | if (marks[i].__isFold) {
56 | var fromPos = marks[i].find(-1);
57 | if (fromPos && fromPos.line === line)
58 | return marks[i];
59 | }
60 | }
61 | }
62 |
63 | function marker(spec) {
64 | if (typeof spec == "string") {
65 | var elt = document.createElement("div");
66 | elt.className = spec + " CodeMirror-guttermarker-subtle";
67 | return elt;
68 | } else {
69 | return spec.cloneNode(true);
70 | }
71 | }
72 |
73 | function updateFoldInfo(cm, from, to) {
74 | var opts = cm.state.foldGutter.options, cur = from - 1;
75 | var minSize = cm.foldOption(opts, "minFoldSize");
76 | var func = cm.foldOption(opts, "rangeFinder");
77 | // we can reuse the built-in indicator element if its className matches the new state
78 | var clsFolded = typeof opts.indicatorFolded == "string" && classTest(opts.indicatorFolded);
79 | var clsOpen = typeof opts.indicatorOpen == "string" && classTest(opts.indicatorOpen);
80 | cm.eachLine(from, to, function(line) {
81 | ++cur;
82 | var mark = null;
83 | var old = line.gutterMarkers;
84 | if (old) old = old[opts.gutter];
85 | if (isFolded(cm, cur)) {
86 | if (clsFolded && old && clsFolded.test(old.className)) return;
87 | mark = marker(opts.indicatorFolded);
88 | } else {
89 | var pos = Pos(cur, 0);
90 | var range = func && func(cm, pos);
91 | if (range && range.to.line - range.from.line >= minSize) {
92 | if (clsOpen && old && clsOpen.test(old.className)) return;
93 | mark = marker(opts.indicatorOpen);
94 | }
95 | }
96 | if (!mark && !old) return;
97 | cm.setGutterMarker(line, opts.gutter, mark);
98 | });
99 | }
100 |
101 | // copied from CodeMirror/src/util/dom.js
102 | function classTest(cls) { return new RegExp("(^|\\s)" + cls + "(?:$|\\s)\\s*") }
103 |
104 | function updateInViewport(cm) {
105 | var vp = cm.getViewport(), state = cm.state.foldGutter;
106 | if (!state) return;
107 | cm.operation(function() {
108 | updateFoldInfo(cm, vp.from, vp.to);
109 | });
110 | state.from = vp.from; state.to = vp.to;
111 | }
112 |
113 | function onGutterClick(cm, line, gutter) {
114 | var state = cm.state.foldGutter;
115 | if (!state) return;
116 | var opts = state.options;
117 | if (gutter != opts.gutter) return;
118 | var folded = isFolded(cm, line);
119 | if (folded) folded.clear();
120 | else cm.foldCode(Pos(line, 0), opts);
121 | }
122 |
123 | function onChange(cm) {
124 | var state = cm.state.foldGutter;
125 | if (!state) return;
126 | var opts = state.options;
127 | state.from = state.to = 0;
128 | clearTimeout(state.changeUpdate);
129 | state.changeUpdate = setTimeout(function() { updateInViewport(cm); }, opts.foldOnChangeTimeSpan || 600);
130 | }
131 |
132 | function onViewportChange(cm) {
133 | var state = cm.state.foldGutter;
134 | if (!state) return;
135 | var opts = state.options;
136 | clearTimeout(state.changeUpdate);
137 | state.changeUpdate = setTimeout(function() {
138 | var vp = cm.getViewport();
139 | if (state.from == state.to || vp.from - state.to > 20 || state.from - vp.to > 20) {
140 | updateInViewport(cm);
141 | } else {
142 | cm.operation(function() {
143 | if (vp.from < state.from) {
144 | updateFoldInfo(cm, vp.from, state.from);
145 | state.from = vp.from;
146 | }
147 | if (vp.to > state.to) {
148 | updateFoldInfo(cm, state.to, vp.to);
149 | state.to = vp.to;
150 | }
151 | });
152 | }
153 | }, opts.updateViewportTimeSpan || 400);
154 | }
155 |
156 | function onFold(cm, from) {
157 | var state = cm.state.foldGutter;
158 | if (!state) return;
159 | var line = from.line;
160 | if (line >= state.from && line < state.to)
161 | updateFoldInfo(cm, line, line + 1);
162 | }
163 | });
164 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/fold/indent-fold.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | function lineIndent(cm, lineNo) {
15 | var text = cm.getLine(lineNo)
16 | var spaceTo = text.search(/\S/)
17 | if (spaceTo == -1 || /\bcomment\b/.test(cm.getTokenTypeAt(CodeMirror.Pos(lineNo, spaceTo + 1))))
18 | return -1
19 | return CodeMirror.countColumn(text, null, cm.getOption("tabSize"))
20 | }
21 |
22 | CodeMirror.registerHelper("fold", "indent", function(cm, start) {
23 | var myIndent = lineIndent(cm, start.line)
24 | if (myIndent < 0) return
25 | var lastLineInFold = null
26 |
27 | // Go through lines until we find a line that definitely doesn't belong in
28 | // the block we're folding, or to the end.
29 | for (var i = start.line + 1, end = cm.lastLine(); i <= end; ++i) {
30 | var indent = lineIndent(cm, i)
31 | if (indent == -1) {
32 | } else if (indent > myIndent) {
33 | // Lines with a greater indent are considered part of the block.
34 | lastLineInFold = i;
35 | } else {
36 | // If this line has non-space, non-comment content, and is
37 | // indented less or equal to the start line, it is the start of
38 | // another block.
39 | break;
40 | }
41 | }
42 | if (lastLineInFold) return {
43 | from: CodeMirror.Pos(start.line, cm.getLine(start.line).length),
44 | to: CodeMirror.Pos(lastLineInFold, cm.getLine(lastLineInFold).length)
45 | };
46 | });
47 |
48 | });
49 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/hint/css-hint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"), require("../../mode/css/css"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror", "../../mode/css/css"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var pseudoClasses = {link: 1, visited: 1, active: 1, hover: 1, focus: 1,
15 | "first-letter": 1, "first-line": 1, "first-child": 1,
16 | before: 1, after: 1, lang: 1};
17 |
18 | CodeMirror.registerHelper("hint", "css", function(cm) {
19 | var cur = cm.getCursor(), token = cm.getTokenAt(cur);
20 | var inner = CodeMirror.innerMode(cm.getMode(), token.state);
21 | if (inner.mode.name != "css") return;
22 |
23 | if (token.type == "keyword" && "!important".indexOf(token.string) == 0)
24 | return {list: ["!important"], from: CodeMirror.Pos(cur.line, token.start),
25 | to: CodeMirror.Pos(cur.line, token.end)};
26 |
27 | var start = token.start, end = cur.ch, word = token.string.slice(0, end - start);
28 | if (/[^\w$_-]/.test(word)) {
29 | word = ""; start = end = cur.ch;
30 | }
31 |
32 | var spec = CodeMirror.resolveMode("text/css");
33 |
34 | var result = [];
35 | function add(keywords) {
36 | for (var name in keywords)
37 | if (!word || name.lastIndexOf(word, 0) == 0)
38 | result.push(name);
39 | }
40 |
41 | var st = inner.state.state;
42 | if (st == "pseudo" || token.type == "variable-3") {
43 | add(pseudoClasses);
44 | } else if (st == "block" || st == "maybeprop") {
45 | add(spec.propertyKeywords);
46 | } else if (st == "prop" || st == "parens" || st == "at" || st == "params") {
47 | add(spec.valueKeywords);
48 | add(spec.colorKeywords);
49 | } else if (st == "media" || st == "media_parens") {
50 | add(spec.mediaTypes);
51 | add(spec.mediaFeatures);
52 | }
53 |
54 | if (result.length) return {
55 | list: result,
56 | from: CodeMirror.Pos(cur.line, start),
57 | to: CodeMirror.Pos(cur.line, end)
58 | };
59 | });
60 | });
61 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/hint/javascript-hint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | var Pos = CodeMirror.Pos;
13 |
14 | function forEach(arr, f) {
15 | for (var i = 0, e = arr.length; i < e; ++i) f(arr[i]);
16 | }
17 |
18 | function arrayContains(arr, item) {
19 | if (!Array.prototype.indexOf) {
20 | var i = arr.length;
21 | while (i--) {
22 | if (arr[i] === item) {
23 | return true;
24 | }
25 | }
26 | return false;
27 | }
28 | return arr.indexOf(item) != -1;
29 | }
30 |
31 | function scriptHint(editor, keywords, getToken, options) {
32 | // Find the token at the cursor
33 | var cur = editor.getCursor(), token = getToken(editor, cur);
34 | if (/^___*/.test(token.string)) return; //ignore anything that starts with "___"
35 | if (/\b(?:string|comment)\b/.test(token.type)) return;
36 | var innerMode = CodeMirror.innerMode(editor.getMode(), token.state);
37 | if (innerMode.mode.helperType === "json") return;
38 | token.state = innerMode.state;
39 |
40 | // If it's not a 'word-style' token, ignore the token.
41 | if (!/^[\w$_]*$/.test(token.string)) {
42 | token = {start: cur.ch, end: cur.ch, string: "", state: token.state,
43 | type: token.string == "." ? "property" : null};
44 | } else if (token.end > cur.ch) {
45 | token.end = cur.ch;
46 | token.string = token.string.slice(0, cur.ch - token.start);
47 | }
48 |
49 | var tprop = token;
50 | // If it is a property, find out what it is a property of.
51 | while (tprop.type == "property") {
52 | tprop = getToken(editor, Pos(cur.line, tprop.start));
53 | if (tprop.string != ".") return;
54 | tprop = getToken(editor, Pos(cur.line, tprop.start));
55 | if (!context) var context = [];
56 | context.push(tprop);
57 | }
58 | return {list: getCompletions(token, context, keywords, options),
59 | from: Pos(cur.line, token.start),
60 | to: Pos(cur.line, token.end)};
61 | }
62 |
63 | function javascriptHint(editor, options) {
64 | return scriptHint(editor, javascriptKeywords,
65 | function (e, cur) {return e.getTokenAt(cur);},
66 | options);
67 | };
68 | CodeMirror.registerHelper("hint", "javascript", javascriptHint);
69 |
70 | function getCoffeeScriptToken(editor, cur) {
71 | // This getToken, it is for coffeescript, imitates the behavior of
72 | // getTokenAt method in javascript.js, that is, returning "property"
73 | // type and treat "." as indepenent token.
74 | var token = editor.getTokenAt(cur);
75 | if (cur.ch == token.start + 1 && token.string.charAt(0) == '.') {
76 | token.end = token.start;
77 | token.string = '.';
78 | token.type = "property";
79 | }
80 | else if (/^\.[\w$_]*$/.test(token.string)) {
81 | token.type = "property";
82 | token.start++;
83 | token.string = token.string.replace(/\./, '');
84 | }
85 | return token;
86 | }
87 |
88 | function coffeescriptHint(editor, options) {
89 | return scriptHint(editor, coffeescriptKeywords, getCoffeeScriptToken, options);
90 | }
91 | CodeMirror.registerHelper("hint", "coffeescript", coffeescriptHint);
92 |
93 | var stringProps = ("charAt charCodeAt indexOf lastIndexOf substring substr slice trim trimLeft trimRight " +
94 | "toUpperCase toLowerCase split concat match replace search").split(" ");
95 | var arrayProps = ("length concat join splice push pop shift unshift slice reverse sort indexOf " +
96 | "lastIndexOf every some filter forEach map reduce reduceRight ").split(" ");
97 | var funcProps = "prototype apply call bind".split(" ");
98 | var javascriptKeywords = ("break case catch class const continue debugger default delete do else export extends false finally for function " +
99 | "if in import instanceof new null return super switch this throw true try typeof var void while with yield").split(" ");
100 | var coffeescriptKeywords = ("and break catch class continue delete do else extends false finally for " +
101 | "if in instanceof isnt new no not null of off on or return switch then throw true try typeof until void while with yes").split(" ");
102 |
103 | function forAllProps(obj, callback) {
104 | if (!Object.getOwnPropertyNames || !Object.getPrototypeOf) {
105 | for (var name in obj) callback(name)
106 | } else {
107 | for (var o = obj; o; o = Object.getPrototypeOf(o))
108 | Object.getOwnPropertyNames(o).forEach(callback)
109 | }
110 | }
111 |
112 | function getCompletions(token, context, keywords, options) {
113 | var found = [], start = token.string, global = options && options.globalScope || window;
114 | function maybeAdd(str) {
115 | if (str.lastIndexOf(start, 0) == 0 && !arrayContains(found, str)) found.push(str);
116 | }
117 | function gatherCompletions(obj) {
118 | if (typeof obj == "string") forEach(stringProps, maybeAdd);
119 | else if (obj instanceof Array) forEach(arrayProps, maybeAdd);
120 | else if (obj instanceof Function) forEach(funcProps, maybeAdd);
121 | forAllProps(obj, maybeAdd)
122 | }
123 |
124 | if (context && context.length) {
125 | // If this is a property, see if it belongs to some object we can
126 | // find in the current environment.
127 | var obj = context.pop(), base;
128 | if (obj.type && obj.type.indexOf("variable") === 0) {
129 | if (options && options.additionalContext)
130 | base = options.additionalContext[obj.string];
131 | if (!options || options.useGlobalScope !== false)
132 | base = base || global[obj.string];
133 | } else if (obj.type == "string") {
134 | base = "";
135 | } else if (obj.type == "atom") {
136 | base = 1;
137 | } else if (obj.type == "function") {
138 | if (global.jQuery != null && (obj.string == '$' || obj.string == 'jQuery') &&
139 | (typeof global.jQuery == 'function'))
140 | base = global.jQuery();
141 | else if (global._ != null && (obj.string == '_') && (typeof global._ == 'function'))
142 | base = global._();
143 | }
144 | while (base != null && context.length)
145 | base = base[context.pop().string];
146 | if (base != null) gatherCompletions(base);
147 | } else {
148 | // If not, just look in the global object and any local scope
149 | // (reading into JS mode internals to get at the local and global variables)
150 | for (var v = token.state.localVars; v; v = v.next) maybeAdd(v.name);
151 | for (var v = token.state.globalVars; v; v = v.next) maybeAdd(v.name);
152 | if (!options || options.useGlobalScope !== false)
153 | gatherCompletions(global);
154 | forEach(keywords, maybeAdd);
155 | }
156 | return found;
157 | }
158 | });
159 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/hint/show-hint.css:
--------------------------------------------------------------------------------
1 | .CodeMirror-hints {
2 | position: absolute;
3 | z-index: 10;
4 | overflow: hidden;
5 | list-style: none;
6 |
7 | margin: 0;
8 | padding: 2px;
9 |
10 | -webkit-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
11 | -moz-box-shadow: 2px 3px 5px rgba(0,0,0,.2);
12 | box-shadow: 2px 3px 5px rgba(0,0,0,.2);
13 | border-radius: 3px;
14 | border: 1px solid silver;
15 |
16 | background: white;
17 | font-size: 90%;
18 | font-family: monospace;
19 |
20 | max-height: 20em;
21 | overflow-y: auto;
22 | }
23 |
24 | .CodeMirror-hint {
25 | margin: 0;
26 | padding: 0 4px;
27 | border-radius: 2px;
28 | white-space: pre;
29 | color: black;
30 | cursor: pointer;
31 | }
32 |
33 | li.CodeMirror-hint-active {
34 | background: #08f;
35 | color: white;
36 | }
37 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/hint/show-hint.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | "use strict";
13 |
14 | var HINT_ELEMENT_CLASS = "CodeMirror-hint";
15 | var ACTIVE_HINT_ELEMENT_CLASS = "CodeMirror-hint-active";
16 |
17 | // This is the old interface, kept around for now to stay
18 | // backwards-compatible.
19 | CodeMirror.showHint = function(cm, getHints, options) {
20 | if (!getHints) return cm.showHint(options);
21 | if (options && options.async) getHints.async = true;
22 | var newOpts = {hint: getHints};
23 | if (options) for (var prop in options) newOpts[prop] = options[prop];
24 | return cm.showHint(newOpts);
25 | };
26 |
27 | CodeMirror.defineExtension("showHint", function(options) {
28 | options = parseOptions(this, this.getCursor("start"), options);
29 | var selections = this.listSelections()
30 | if (selections.length > 1) return;
31 | // By default, don't allow completion when something is selected.
32 | // A hint function can have a `supportsSelection` property to
33 | // indicate that it can handle selections.
34 | if (this.somethingSelected()) {
35 | if (!options.hint.supportsSelection) return;
36 | // Don't try with cross-line selections
37 | for (var i = 0; i < selections.length; i++)
38 | if (selections[i].head.line != selections[i].anchor.line) return;
39 | }
40 |
41 | if (this.state.completionActive) this.state.completionActive.close();
42 | var completion = this.state.completionActive = new Completion(this, options);
43 | if (!completion.options.hint) return;
44 |
45 | CodeMirror.signal(this, "startCompletion", this);
46 | completion.update(true);
47 | });
48 |
49 | function Completion(cm, options) {
50 | this.cm = cm;
51 | this.options = options;
52 | this.widget = null;
53 | this.debounce = 0;
54 | this.tick = 0;
55 | this.startPos = this.cm.getCursor("start");
56 | this.startLen = this.cm.getLine(this.startPos.line).length - this.cm.getSelection().length;
57 |
58 | var self = this;
59 | cm.on("cursorActivity", this.activityFunc = function() { self.cursorActivity(); });
60 | }
61 |
62 | var requestAnimationFrame = window.requestAnimationFrame || function(fn) {
63 | return setTimeout(fn, 1000/60);
64 | };
65 | var cancelAnimationFrame = window.cancelAnimationFrame || clearTimeout;
66 |
67 | Completion.prototype = {
68 | close: function() {
69 | if (!this.active()) return;
70 | this.cm.state.completionActive = null;
71 | this.tick = null;
72 | this.cm.off("cursorActivity", this.activityFunc);
73 |
74 | if (this.widget && this.data) CodeMirror.signal(this.data, "close");
75 | if (this.widget) this.widget.close();
76 | CodeMirror.signal(this.cm, "endCompletion", this.cm);
77 | },
78 |
79 | active: function() {
80 | return this.cm.state.completionActive == this;
81 | },
82 |
83 | pick: function(data, i) {
84 | var completion = data.list[i];
85 | if (completion.hint) completion.hint(this.cm, data, completion);
86 | else this.cm.replaceRange(getText(completion), completion.from || data.from,
87 | completion.to || data.to, "complete");
88 | CodeMirror.signal(data, "pick", completion);
89 | this.close();
90 | },
91 |
92 | cursorActivity: function() {
93 | if (this.debounce) {
94 | cancelAnimationFrame(this.debounce);
95 | this.debounce = 0;
96 | }
97 |
98 | var pos = this.cm.getCursor(), line = this.cm.getLine(pos.line);
99 | if (pos.line != this.startPos.line || line.length - pos.ch != this.startLen - this.startPos.ch ||
100 | pos.ch < this.startPos.ch || this.cm.somethingSelected() ||
101 | (!pos.ch || this.options.closeCharacters.test(line.charAt(pos.ch - 1)))) {
102 | this.close();
103 | } else {
104 | var self = this;
105 | this.debounce = requestAnimationFrame(function() {self.update();});
106 | if (this.widget) this.widget.disable();
107 | }
108 | },
109 |
110 | update: function(first) {
111 | if (this.tick == null) return
112 | var self = this, myTick = ++this.tick
113 | fetchHints(this.options.hint, this.cm, this.options, function(data) {
114 | if (self.tick == myTick) self.finishUpdate(data, first)
115 | })
116 | },
117 |
118 | finishUpdate: function(data, first) {
119 | if (this.data) CodeMirror.signal(this.data, "update");
120 |
121 | var picked = (this.widget && this.widget.picked) || (first && this.options.completeSingle);
122 | if (this.widget) this.widget.close();
123 |
124 | this.data = data;
125 |
126 | if (data && data.list.length) {
127 | if (picked && data.list.length == 1) {
128 | this.pick(data, 0);
129 | } else {
130 | this.widget = new Widget(this, data);
131 | CodeMirror.signal(data, "shown");
132 | }
133 | }
134 | }
135 | };
136 |
137 | function parseOptions(cm, pos, options) {
138 | var editor = cm.options.hintOptions;
139 | var out = {};
140 | for (var prop in defaultOptions) out[prop] = defaultOptions[prop];
141 | if (editor) for (var prop in editor)
142 | if (editor[prop] !== undefined) out[prop] = editor[prop];
143 | if (options) for (var prop in options)
144 | if (options[prop] !== undefined) out[prop] = options[prop];
145 | if (out.hint.resolve) out.hint = out.hint.resolve(cm, pos)
146 | return out;
147 | }
148 |
149 | function getText(completion) {
150 | if (typeof completion == "string") return completion;
151 | else return completion.text;
152 | }
153 |
154 | function buildKeyMap(completion, handle) {
155 | var baseMap = {
156 | Up: function() {handle.moveFocus(-1);},
157 | Down: function() {handle.moveFocus(1);},
158 | PageUp: function() {handle.moveFocus(-handle.menuSize() + 1, true);},
159 | PageDown: function() {handle.moveFocus(handle.menuSize() - 1, true);},
160 | Home: function() {handle.setFocus(0);},
161 | End: function() {handle.setFocus(handle.length - 1);},
162 | Enter: handle.pick,
163 | Tab: handle.pick,
164 | Esc: handle.close
165 | };
166 | var custom = completion.options.customKeys;
167 | var ourMap = custom ? {} : baseMap;
168 | function addBinding(key, val) {
169 | var bound;
170 | if (typeof val != "string")
171 | bound = function(cm) { return val(cm, handle); };
172 | // This mechanism is deprecated
173 | else if (baseMap.hasOwnProperty(val))
174 | bound = baseMap[val];
175 | else
176 | bound = val;
177 | ourMap[key] = bound;
178 | }
179 | if (custom)
180 | for (var key in custom) if (custom.hasOwnProperty(key))
181 | addBinding(key, custom[key]);
182 | var extra = completion.options.extraKeys;
183 | if (extra)
184 | for (var key in extra) if (extra.hasOwnProperty(key))
185 | addBinding(key, extra[key]);
186 | return ourMap;
187 | }
188 |
189 | function getHintElement(hintsElement, el) {
190 | while (el && el != hintsElement) {
191 | if (el.nodeName.toUpperCase() === "LI" && el.parentNode == hintsElement) return el;
192 | el = el.parentNode;
193 | }
194 | }
195 |
196 | function Widget(completion, data) {
197 | this.completion = completion;
198 | this.data = data;
199 | this.picked = false;
200 | var widget = this, cm = completion.cm;
201 |
202 | var hints = this.hints = document.createElement("ul");
203 | var theme = completion.cm.options.theme;
204 | hints.className = "CodeMirror-hints " + theme;
205 | this.selectedHint = data.selectedHint || 0;
206 |
207 | var completions = data.list;
208 | for (var i = 0; i < completions.length; ++i) {
209 | var elt = hints.appendChild(document.createElement("li")), cur = completions[i];
210 | var className = HINT_ELEMENT_CLASS + (i != this.selectedHint ? "" : " " + ACTIVE_HINT_ELEMENT_CLASS);
211 | if (cur.className != null) className = cur.className + " " + className;
212 | elt.className = className;
213 | if (cur.render) cur.render(elt, data, cur);
214 | else elt.appendChild(document.createTextNode(cur.displayText || getText(cur)));
215 | elt.hintId = i;
216 | }
217 |
218 | var pos = cm.cursorCoords(completion.options.alignWithWord ? data.from : null);
219 | var left = pos.left, top = pos.bottom, below = true;
220 | hints.style.left = left + "px";
221 | hints.style.top = top + "px";
222 | // If we're at the edge of the screen, then we want the menu to appear on the left of the cursor.
223 | var winW = window.innerWidth || Math.max(document.body.offsetWidth, document.documentElement.offsetWidth);
224 | var winH = window.innerHeight || Math.max(document.body.offsetHeight, document.documentElement.offsetHeight);
225 | (completion.options.container || document.body).appendChild(hints);
226 | var box = hints.getBoundingClientRect(), overlapY = box.bottom - winH;
227 | var scrolls = hints.scrollHeight > hints.clientHeight + 1
228 | var startScroll = cm.getScrollInfo();
229 |
230 | if (overlapY > 0) {
231 | var height = box.bottom - box.top, curTop = pos.top - (pos.bottom - box.top);
232 | if (curTop - height > 0) { // Fits above cursor
233 | hints.style.top = (top = pos.top - height) + "px";
234 | below = false;
235 | } else if (height > winH) {
236 | hints.style.height = (winH - 5) + "px";
237 | hints.style.top = (top = pos.bottom - box.top) + "px";
238 | var cursor = cm.getCursor();
239 | if (data.from.ch != cursor.ch) {
240 | pos = cm.cursorCoords(cursor);
241 | hints.style.left = (left = pos.left) + "px";
242 | box = hints.getBoundingClientRect();
243 | }
244 | }
245 | }
246 | var overlapX = box.right - winW;
247 | if (overlapX > 0) {
248 | if (box.right - box.left > winW) {
249 | hints.style.width = (winW - 5) + "px";
250 | overlapX -= (box.right - box.left) - winW;
251 | }
252 | hints.style.left = (left = pos.left - overlapX) + "px";
253 | }
254 | if (scrolls) for (var node = hints.firstChild; node; node = node.nextSibling)
255 | node.style.paddingRight = cm.display.nativeBarWidth + "px"
256 |
257 | cm.addKeyMap(this.keyMap = buildKeyMap(completion, {
258 | moveFocus: function(n, avoidWrap) { widget.changeActive(widget.selectedHint + n, avoidWrap); },
259 | setFocus: function(n) { widget.changeActive(n); },
260 | menuSize: function() { return widget.screenAmount(); },
261 | length: completions.length,
262 | close: function() { completion.close(); },
263 | pick: function() { widget.pick(); },
264 | data: data
265 | }));
266 |
267 | if (completion.options.closeOnUnfocus) {
268 | var closingOnBlur;
269 | cm.on("blur", this.onBlur = function() { closingOnBlur = setTimeout(function() { completion.close(); }, 100); });
270 | cm.on("focus", this.onFocus = function() { clearTimeout(closingOnBlur); });
271 | }
272 |
273 | cm.on("scroll", this.onScroll = function() {
274 | var curScroll = cm.getScrollInfo(), editor = cm.getWrapperElement().getBoundingClientRect();
275 | var newTop = top + startScroll.top - curScroll.top;
276 | var point = newTop - (window.pageYOffset || (document.documentElement || document.body).scrollTop);
277 | if (!below) point += hints.offsetHeight;
278 | if (point <= editor.top || point >= editor.bottom) return completion.close();
279 | hints.style.top = newTop + "px";
280 | hints.style.left = (left + startScroll.left - curScroll.left) + "px";
281 | });
282 |
283 | CodeMirror.on(hints, "dblclick", function(e) {
284 | var t = getHintElement(hints, e.target || e.srcElement);
285 | if (t && t.hintId != null) {widget.changeActive(t.hintId); widget.pick();}
286 | });
287 |
288 | CodeMirror.on(hints, "click", function(e) {
289 | var t = getHintElement(hints, e.target || e.srcElement);
290 | if (t && t.hintId != null) {
291 | widget.changeActive(t.hintId);
292 | if (completion.options.completeOnSingleClick) widget.pick();
293 | }
294 | });
295 |
296 | CodeMirror.on(hints, "mousedown", function() {
297 | setTimeout(function(){cm.focus();}, 20);
298 | });
299 |
300 | CodeMirror.signal(data, "select", completions[this.selectedHint], hints.childNodes[this.selectedHint]);
301 | return true;
302 | }
303 |
304 | Widget.prototype = {
305 | close: function() {
306 | if (this.completion.widget != this) return;
307 | this.completion.widget = null;
308 | this.hints.parentNode.removeChild(this.hints);
309 | this.completion.cm.removeKeyMap(this.keyMap);
310 |
311 | var cm = this.completion.cm;
312 | if (this.completion.options.closeOnUnfocus) {
313 | cm.off("blur", this.onBlur);
314 | cm.off("focus", this.onFocus);
315 | }
316 | cm.off("scroll", this.onScroll);
317 | },
318 |
319 | disable: function() {
320 | this.completion.cm.removeKeyMap(this.keyMap);
321 | var widget = this;
322 | this.keyMap = {Enter: function() { widget.picked = true; }};
323 | this.completion.cm.addKeyMap(this.keyMap);
324 | },
325 |
326 | pick: function() {
327 | this.completion.pick(this.data, this.selectedHint);
328 | },
329 |
330 | changeActive: function(i, avoidWrap) {
331 | if (i >= this.data.list.length)
332 | i = avoidWrap ? this.data.list.length - 1 : 0;
333 | else if (i < 0)
334 | i = avoidWrap ? 0 : this.data.list.length - 1;
335 | if (this.selectedHint == i) return;
336 | var node = this.hints.childNodes[this.selectedHint];
337 | if (node) node.className = node.className.replace(" " + ACTIVE_HINT_ELEMENT_CLASS, "");
338 | node = this.hints.childNodes[this.selectedHint = i];
339 | node.className += " " + ACTIVE_HINT_ELEMENT_CLASS;
340 | if (node.offsetTop < this.hints.scrollTop)
341 | this.hints.scrollTop = node.offsetTop - 3;
342 | else if (node.offsetTop + node.offsetHeight > this.hints.scrollTop + this.hints.clientHeight)
343 | this.hints.scrollTop = node.offsetTop + node.offsetHeight - this.hints.clientHeight + 3;
344 | CodeMirror.signal(this.data, "select", this.data.list[this.selectedHint], node);
345 | },
346 |
347 | screenAmount: function() {
348 | return Math.floor(this.hints.clientHeight / this.hints.firstChild.offsetHeight) || 1;
349 | }
350 | };
351 |
352 | function applicableHelpers(cm, helpers) {
353 | if (!cm.somethingSelected()) return helpers
354 | var result = []
355 | for (var i = 0; i < helpers.length; i++)
356 | if (helpers[i].supportsSelection) result.push(helpers[i])
357 | return result
358 | }
359 |
360 | function fetchHints(hint, cm, options, callback) {
361 | if (hint.async) {
362 | hint(cm, callback, options)
363 | } else {
364 | var result = hint(cm, options)
365 | if (result && result.then) result.then(callback)
366 | else callback(result)
367 | }
368 | }
369 |
370 | function resolveAutoHints(cm, pos) {
371 | var helpers = cm.getHelpers(pos, "hint"), words
372 | if (helpers.length) {
373 | var resolved = function(cm, callback, options) {
374 | var app = applicableHelpers(cm, helpers);
375 | function run(i) {
376 | if (i == app.length) return callback(null)
377 | fetchHints(app[i], cm, options, function(result) {
378 | if (result && result.list.length > 0) callback(result)
379 | else run(i + 1)
380 | })
381 | }
382 | run(0)
383 | }
384 | resolved.async = true
385 | resolved.supportsSelection = true
386 | return resolved
387 | } else if (words = cm.getHelper(cm.getCursor(), "hintWords")) {
388 | return function(cm) { return CodeMirror.hint.fromList(cm, {words: words}) }
389 | } else if (CodeMirror.hint.anyword) {
390 | return function(cm, options) { return CodeMirror.hint.anyword(cm, options) }
391 | } else {
392 | return function() {}
393 | }
394 | }
395 |
396 | CodeMirror.registerHelper("hint", "auto", {
397 | resolve: resolveAutoHints
398 | });
399 |
400 | CodeMirror.registerHelper("hint", "fromList", function(cm, options) {
401 | var cur = cm.getCursor(), token = cm.getTokenAt(cur)
402 | var term, from = CodeMirror.Pos(cur.line, token.start), to = cur
403 | if (token.start < cur.ch && /\w/.test(token.string.charAt(cur.ch - token.start - 1))) {
404 | term = token.string.substr(0, cur.ch - token.start)
405 | } else {
406 | term = ""
407 | from = cur
408 | }
409 | var found = [];
410 | for (var i = 0; i < options.words.length; i++) {
411 | var word = options.words[i];
412 | if (word.slice(0, term.length) == term)
413 | found.push(word);
414 | }
415 |
416 | if (found.length) return {list: found, from: from, to: to};
417 | });
418 |
419 | CodeMirror.commands.autocomplete = CodeMirror.showHint;
420 |
421 | var defaultOptions = {
422 | hint: CodeMirror.hint.auto,
423 | completeSingle: true,
424 | alignWithWord: true,
425 | closeCharacters: /[\s()\[\]{};:>,]/,
426 | closeOnUnfocus: true,
427 | completeOnSingleClick: true,
428 | container: null,
429 | customKeys: null,
430 | extraKeys: null
431 | };
432 |
433 | CodeMirror.defineOption("hintOptions", null);
434 | });
435 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/matchbrackets.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | var ie_lt8 = /MSIE \d/.test(navigator.userAgent) &&
13 | (document.documentMode == null || document.documentMode < 8);
14 |
15 | var Pos = CodeMirror.Pos;
16 |
17 | var matching = {"(": ")>", ")": "(<", "[": "]>", "]": "[<", "{": "}>", "}": "{<"};
18 |
19 | function findMatchingBracket(cm, where, config) {
20 | var line = cm.getLineHandle(where.line), pos = where.ch - 1;
21 | var afterCursor = config && config.afterCursor
22 | if (afterCursor == null)
23 | afterCursor = /(^| )cm-fat-cursor($| )/.test(cm.getWrapperElement().className)
24 |
25 | // A cursor is defined as between two characters, but in in vim command mode
26 | // (i.e. not insert mode), the cursor is visually represented as a
27 | // highlighted box on top of the 2nd character. Otherwise, we allow matches
28 | // from before or after the cursor.
29 | var match = (!afterCursor && pos >= 0 && matching[line.text.charAt(pos)]) ||
30 | matching[line.text.charAt(++pos)];
31 | if (!match) return null;
32 | var dir = match.charAt(1) == ">" ? 1 : -1;
33 | if (config && config.strict && (dir > 0) != (pos == where.ch)) return null;
34 | var style = cm.getTokenTypeAt(Pos(where.line, pos + 1));
35 |
36 | var found = scanForBracket(cm, Pos(where.line, pos + (dir > 0 ? 1 : 0)), dir, style || null, config);
37 | if (found == null) return null;
38 | return {from: Pos(where.line, pos), to: found && found.pos,
39 | match: found && found.ch == match.charAt(0), forward: dir > 0};
40 | }
41 |
42 | // bracketRegex is used to specify which type of bracket to scan
43 | // should be a regexp, e.g. /[[\]]/
44 | //
45 | // Note: If "where" is on an open bracket, then this bracket is ignored.
46 | //
47 | // Returns false when no bracket was found, null when it reached
48 | // maxScanLines and gave up
49 | function scanForBracket(cm, where, dir, style, config) {
50 | var maxScanLen = (config && config.maxScanLineLength) || 10000;
51 | var maxScanLines = (config && config.maxScanLines) || 1000;
52 |
53 | var stack = [];
54 | var re = config && config.bracketRegex ? config.bracketRegex : /[(){}[\]]/;
55 | var lineEnd = dir > 0 ? Math.min(where.line + maxScanLines, cm.lastLine() + 1)
56 | : Math.max(cm.firstLine() - 1, where.line - maxScanLines);
57 | for (var lineNo = where.line; lineNo != lineEnd; lineNo += dir) {
58 | var line = cm.getLine(lineNo);
59 | if (!line) continue;
60 | var pos = dir > 0 ? 0 : line.length - 1, end = dir > 0 ? line.length : -1;
61 | if (line.length > maxScanLen) continue;
62 | if (lineNo == where.line) pos = where.ch - (dir < 0 ? 1 : 0);
63 | for (; pos != end; pos += dir) {
64 | var ch = line.charAt(pos);
65 | if (re.test(ch) && (style === undefined || cm.getTokenTypeAt(Pos(lineNo, pos + 1)) == style)) {
66 | var match = matching[ch];
67 | if ((match.charAt(1) == ">") == (dir > 0)) stack.push(ch);
68 | else if (!stack.length) return {pos: Pos(lineNo, pos), ch: ch};
69 | else stack.pop();
70 | }
71 | }
72 | }
73 | return lineNo - dir == (dir > 0 ? cm.lastLine() : cm.firstLine()) ? false : null;
74 | }
75 |
76 | function matchBrackets(cm, autoclear, config) {
77 | // Disable brace matching in long lines, since it'll cause hugely slow updates
78 | var maxHighlightLen = cm.state.matchBrackets.maxHighlightLineLength || 1000;
79 | var marks = [], ranges = cm.listSelections();
80 | for (var i = 0; i < ranges.length; i++) {
81 | var match = ranges[i].empty() && findMatchingBracket(cm, ranges[i].head, config);
82 | if (match && cm.getLine(match.from.line).length <= maxHighlightLen) {
83 | var style = match.match ? "CodeMirror-matchingbracket" : "CodeMirror-nonmatchingbracket";
84 | marks.push(cm.markText(match.from, Pos(match.from.line, match.from.ch + 1), {className: style}));
85 | if (match.to && cm.getLine(match.to.line).length <= maxHighlightLen)
86 | marks.push(cm.markText(match.to, Pos(match.to.line, match.to.ch + 1), {className: style}));
87 | }
88 | }
89 |
90 | if (marks.length) {
91 | // Kludge to work around the IE bug from issue #1193, where text
92 | // input stops going to the textare whever this fires.
93 | if (ie_lt8 && cm.state.focused) cm.focus();
94 |
95 | var clear = function() {
96 | cm.operation(function() {
97 | for (var i = 0; i < marks.length; i++) marks[i].clear();
98 | });
99 | };
100 | if (autoclear) setTimeout(clear, 800);
101 | else return clear;
102 | }
103 | }
104 |
105 | function doMatchBrackets(cm) {
106 | cm.operation(function() {
107 | if (cm.state.matchBrackets.currentlyHighlighted) {
108 | cm.state.matchBrackets.currentlyHighlighted();
109 | cm.state.matchBrackets.currentlyHighlighted = null;
110 | }
111 | cm.state.matchBrackets.currentlyHighlighted = matchBrackets(cm, false, cm.state.matchBrackets);
112 | });
113 | }
114 |
115 | CodeMirror.defineOption("matchBrackets", false, function(cm, val, old) {
116 | if (old && old != CodeMirror.Init) {
117 | cm.off("cursorActivity", doMatchBrackets);
118 | if (cm.state.matchBrackets && cm.state.matchBrackets.currentlyHighlighted) {
119 | cm.state.matchBrackets.currentlyHighlighted();
120 | cm.state.matchBrackets.currentlyHighlighted = null;
121 | }
122 | }
123 | if (val) {
124 | cm.state.matchBrackets = typeof val == "object" ? val : {};
125 | cm.on("cursorActivity", doMatchBrackets);
126 | }
127 | });
128 |
129 | CodeMirror.defineExtension("matchBrackets", function() {matchBrackets(this, true);});
130 | CodeMirror.defineExtension("findMatchingBracket", function(pos, config, oldConfig){
131 | // Backwards-compatibility kludge
132 | if (oldConfig || typeof config == "boolean") {
133 | if (!oldConfig) {
134 | config = config ? {strict: true} : null
135 | } else {
136 | oldConfig.strict = config
137 | config = oldConfig
138 | }
139 | }
140 | return findMatchingBracket(this, pos, config)
141 | });
142 | CodeMirror.defineExtension("scanForBracket", function(pos, dir, style, config){
143 | return scanForBracket(this, pos, dir, style, config);
144 | });
145 | });
146 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/placeholder.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | (function(mod) {
5 | if (typeof exports == "object" && typeof module == "object") // CommonJS
6 | mod(require("../../lib/codemirror"));
7 | else if (typeof define == "function" && define.amd) // AMD
8 | define(["../../lib/codemirror"], mod);
9 | else // Plain browser env
10 | mod(CodeMirror);
11 | })(function(CodeMirror) {
12 | CodeMirror.defineOption("placeholder", "", function(cm, val, old) {
13 | var prev = old && old != CodeMirror.Init;
14 | if (val && !prev) {
15 | cm.on("blur", onBlur);
16 | cm.on("change", onChange);
17 | cm.on("swapDoc", onChange);
18 | onChange(cm);
19 | } else if (!val && prev) {
20 | cm.off("blur", onBlur);
21 | cm.off("change", onChange);
22 | cm.off("swapDoc", onChange);
23 | clearPlaceholder(cm);
24 | var wrapper = cm.getWrapperElement();
25 | wrapper.className = wrapper.className.replace(" CodeMirror-empty", "");
26 | }
27 |
28 | if (val && !cm.hasFocus()) onBlur(cm);
29 | });
30 |
31 | function clearPlaceholder(cm) {
32 | if (cm.state.placeholder) {
33 | cm.state.placeholder.parentNode.removeChild(cm.state.placeholder);
34 | cm.state.placeholder = null;
35 | }
36 | }
37 | function setPlaceholder(cm) {
38 | clearPlaceholder(cm);
39 | var elt = cm.state.placeholder = document.createElement("pre");
40 | elt.style.cssText = "height: 0; overflow: visible";
41 | elt.style.direction = cm.getOption("direction");
42 | elt.className = "CodeMirror-placeholder";
43 | var placeHolder = cm.getOption("placeholder")
44 | if (typeof placeHolder == "string") placeHolder = document.createTextNode(placeHolder)
45 | elt.appendChild(placeHolder)
46 | cm.display.lineSpace.insertBefore(elt, cm.display.lineSpace.firstChild);
47 | }
48 |
49 | function onBlur(cm) {
50 | if (isEmpty(cm)) setPlaceholder(cm);
51 | }
52 | function onChange(cm) {
53 | var wrapper = cm.getWrapperElement(), empty = isEmpty(cm);
54 | wrapper.className = wrapper.className.replace(" CodeMirror-empty", "") + (empty ? " CodeMirror-empty" : "");
55 |
56 | if (empty) setPlaceholder(cm);
57 | else clearPlaceholder(cm);
58 | }
59 |
60 | function isEmpty(cm) {
61 | return (cm.lineCount() === 1) && (cm.getLine(0) === "");
62 | }
63 | });
64 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/addon/search.js:
--------------------------------------------------------------------------------
1 | // CodeMirror, copyright (c) by Marijn Haverbeke and others
2 | // Distributed under an MIT license: https://codemirror.net/LICENSE
3 |
4 | // Define search commands. Depends on dialog.js or another
5 | // implementation of the openDialog method.
6 |
7 | // Replace works a little oddly -- it will do the replace on the next
8 | // Ctrl-G (or whatever is bound to findNext) press. You prevent a
9 | // replace by making sure the match is no longer selected when hitting
10 | // Ctrl-G.
11 |
12 | (function(mod) {
13 | if (typeof exports == "object" && typeof module == "object") // CommonJS
14 | mod(require("../../lib/codemirror"), require("./searchcursor"), require("../dialog/dialog"));
15 | else if (typeof define == "function" && define.amd) // AMD
16 | define(["../../lib/codemirror", "./searchcursor", "../dialog/dialog"], mod);
17 | else // Plain browser env
18 | mod(CodeMirror);
19 | })(function(CodeMirror) {
20 | "use strict";
21 |
22 | function searchOverlay(query, caseInsensitive) {
23 | if (typeof query == "string")
24 | query = new RegExp(query.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"), caseInsensitive ? "gi" : "g");
25 | else if (!query.global)
26 | query = new RegExp(query.source, query.ignoreCase ? "gi" : "g");
27 |
28 | return {token: function(stream) {
29 | query.lastIndex = stream.pos;
30 | var match = query.exec(stream.string);
31 | if (match && match.index == stream.pos) {
32 | stream.pos += match[0].length || 1;
33 | return "searching";
34 | } else if (match) {
35 | stream.pos = match.index;
36 | } else {
37 | stream.skipToEnd();
38 | }
39 | }};
40 | }
41 |
42 | function SearchState() {
43 | this.posFrom = this.posTo = this.lastQuery = this.query = null;
44 | this.overlay = null;
45 | }
46 |
47 | function getSearchState(cm) {
48 | return cm.state.search || (cm.state.search = new SearchState());
49 | }
50 |
51 | function queryCaseInsensitive(query) {
52 | return typeof query == "string" && query == query.toLowerCase();
53 | }
54 |
55 | function getSearchCursor(cm, query, pos) {
56 | // Heuristic: if the query string is all lowercase, do a case insensitive search.
57 | return cm.getSearchCursor(query, pos, {caseFold: queryCaseInsensitive(query), multiline: true});
58 | }
59 |
60 | function persistentDialog(cm, text, deflt, onEnter, onKeyDown) {
61 | cm.openDialog(text, onEnter, {
62 | value: deflt,
63 | selectValueOnOpen: true,
64 | closeOnEnter: false,
65 | onClose: function() { clearSearch(cm); },
66 | onKeyDown: onKeyDown
67 | });
68 | }
69 |
70 | function dialog(cm, text, shortText, deflt, f) {
71 | if (cm.openDialog) cm.openDialog(text, f, {value: deflt, selectValueOnOpen: true});
72 | else f(prompt(shortText, deflt));
73 | }
74 |
75 | function confirmDialog(cm, text, shortText, fs) {
76 | if (cm.openConfirm) cm.openConfirm(text, fs);
77 | else if (confirm(shortText)) fs[0]();
78 | }
79 |
80 | function parseString(string) {
81 | return string.replace(/\\(.)/g, function(_, ch) {
82 | if (ch == "n") return "\n"
83 | if (ch == "r") return "\r"
84 | return ch
85 | })
86 | }
87 |
88 | function parseQuery(query) {
89 | var isRE = query.match(/^\/(.*)\/([a-z]*)$/);
90 | if (isRE) {
91 | try { query = new RegExp(isRE[1], isRE[2].indexOf("i") == -1 ? "" : "i"); }
92 | catch(e) {} // Not a regular expression after all, do a string search
93 | } else {
94 | query = parseString(query)
95 | }
96 | if (typeof query == "string" ? query == "" : query.test(""))
97 | query = /x^/;
98 | return query;
99 | }
100 |
101 | function startSearch(cm, state, query) {
102 | state.queryText = query;
103 | state.query = parseQuery(query);
104 | cm.removeOverlay(state.overlay, queryCaseInsensitive(state.query));
105 | state.overlay = searchOverlay(state.query, queryCaseInsensitive(state.query));
106 | cm.addOverlay(state.overlay);
107 | if (cm.showMatchesOnScrollbar) {
108 | if (state.annotate) { state.annotate.clear(); state.annotate = null; }
109 | state.annotate = cm.showMatchesOnScrollbar(state.query, queryCaseInsensitive(state.query));
110 | }
111 | }
112 |
113 | function doSearch(cm, rev, persistent, immediate) {
114 | var state = getSearchState(cm);
115 | if (state.query) return findNext(cm, rev);
116 | var q = cm.getSelection() || state.lastQuery;
117 | if (q instanceof RegExp && q.source == "x^") q = null
118 | if (persistent && cm.openDialog) {
119 | var hiding = null
120 | var searchNext = function(query, event) {
121 | CodeMirror.e_stop(event);
122 | if (!query) return;
123 | if (query != state.queryText) {
124 | startSearch(cm, state, query);
125 | state.posFrom = state.posTo = cm.getCursor();
126 | }
127 | if (hiding) hiding.style.opacity = 1
128 | findNext(cm, event.shiftKey, function(_, to) {
129 | var dialog
130 | if (to.line < 3 && document.querySelector &&
131 | (dialog = cm.display.wrapper.querySelector(".CodeMirror-dialog")) &&
132 | dialog.getBoundingClientRect().bottom - 4 > cm.cursorCoords(to, "window").top)
133 | (hiding = dialog).style.opacity = .4
134 | })
135 | };
136 | persistentDialog(cm, getQueryDialog(cm), q, searchNext, function(event, query) {
137 | var keyName = CodeMirror.keyName(event)
138 | var extra = cm.getOption('extraKeys'), cmd = (extra && extra[keyName]) || CodeMirror.keyMap[cm.getOption("keyMap")][keyName]
139 | if (cmd == "findNext" || cmd == "findPrev" ||
140 | cmd == "findPersistentNext" || cmd == "findPersistentPrev") {
141 | CodeMirror.e_stop(event);
142 | startSearch(cm, getSearchState(cm), query);
143 | cm.execCommand(cmd);
144 | } else if (cmd == "find" || cmd == "findPersistent") {
145 | CodeMirror.e_stop(event);
146 | searchNext(query, event);
147 | }
148 | });
149 | if (immediate && q) {
150 | startSearch(cm, state, q);
151 | findNext(cm, rev);
152 | }
153 | } else {
154 | dialog(cm, getQueryDialog(cm), "Search for:", q, function(query) {
155 | if (query && !state.query) cm.operation(function() {
156 | startSearch(cm, state, query);
157 | state.posFrom = state.posTo = cm.getCursor();
158 | findNext(cm, rev);
159 | });
160 | });
161 | }
162 | }
163 |
164 | function findNext(cm, rev, callback) {cm.operation(function() {
165 | var state = getSearchState(cm);
166 | var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
167 | if (!cursor.find(rev)) {
168 | cursor = getSearchCursor(cm, state.query, rev ? CodeMirror.Pos(cm.lastLine()) : CodeMirror.Pos(cm.firstLine(), 0));
169 | if (!cursor.find(rev)) return;
170 | }
171 | cm.setSelection(cursor.from(), cursor.to());
172 | cm.scrollIntoView({from: cursor.from(), to: cursor.to()}, 20);
173 | state.posFrom = cursor.from(); state.posTo = cursor.to();
174 | if (callback) callback(cursor.from(), cursor.to())
175 | });}
176 |
177 | function clearSearch(cm) {cm.operation(function() {
178 | var state = getSearchState(cm);
179 | state.lastQuery = state.query;
180 | if (!state.query) return;
181 | state.query = state.queryText = null;
182 | cm.removeOverlay(state.overlay);
183 | if (state.annotate) { state.annotate.clear(); state.annotate = null; }
184 | });}
185 |
186 |
187 | function getQueryDialog(cm) {
188 | return '' + cm.phrase("Search:") + ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + '';
189 | }
190 | function getReplaceQueryDialog(cm) {
191 | return ' ' + cm.phrase("(Use /re/ syntax for regexp search)") + '';
192 | }
193 | function getReplacementQueryDialog(cm) {
194 | return '' + cm.phrase("With:") + ' ';
195 | }
196 | function getDoReplaceConfirm(cm) {
197 | return '' + cm.phrase("Replace?") + ' ';
198 | }
199 |
200 | function replaceAll(cm, query, text) {
201 | cm.operation(function() {
202 | for (var cursor = getSearchCursor(cm, query); cursor.findNext();) {
203 | if (typeof query != "string") {
204 | var match = cm.getRange(cursor.from(), cursor.to()).match(query);
205 | cursor.replace(text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
206 | } else cursor.replace(text);
207 | }
208 | });
209 | }
210 |
211 | function replace(cm, all) {
212 | if (cm.getOption("readOnly")) return;
213 | var query = cm.getSelection() || getSearchState(cm).lastQuery;
214 | var dialogText = '' + (all ? cm.phrase("Replace all:") : cm.phrase("Replace:")) + '';
215 | dialog(cm, dialogText + getReplaceQueryDialog(cm), dialogText, query, function(query) {
216 | if (!query) return;
217 | query = parseQuery(query);
218 | dialog(cm, getReplacementQueryDialog(cm), cm.phrase("Replace with:"), "", function(text) {
219 | text = parseString(text)
220 | if (all) {
221 | replaceAll(cm, query, text)
222 | } else {
223 | clearSearch(cm);
224 | var cursor = getSearchCursor(cm, query, cm.getCursor("from"));
225 | var advance = function() {
226 | var start = cursor.from(), match;
227 | if (!(match = cursor.findNext())) {
228 | cursor = getSearchCursor(cm, query);
229 | if (!(match = cursor.findNext()) ||
230 | (start && cursor.from().line == start.line && cursor.from().ch == start.ch)) return;
231 | }
232 | cm.setSelection(cursor.from(), cursor.to());
233 | cm.scrollIntoView({from: cursor.from(), to: cursor.to()});
234 | confirmDialog(cm, getDoReplaceConfirm(cm), cm.phrase("Replace?"),
235 | [function() {doReplace(match);}, advance,
236 | function() {replaceAll(cm, query, text)}]);
237 | };
238 | var doReplace = function(match) {
239 | cursor.replace(typeof query == "string" ? text :
240 | text.replace(/\$(\d)/g, function(_, i) {return match[i];}));
241 | advance();
242 | };
243 | advance();
244 | }
245 | });
246 | });
247 | }
248 |
249 | CodeMirror.commands.find = function(cm) {clearSearch(cm); doSearch(cm);};
250 | CodeMirror.commands.findPersistent = function(cm) {clearSearch(cm); doSearch(cm, false, true);};
251 | CodeMirror.commands.findPersistentNext = function(cm) {doSearch(cm, false, true, true);};
252 | CodeMirror.commands.findPersistentPrev = function(cm) {doSearch(cm, true, true, true);};
253 | CodeMirror.commands.findNext = doSearch;
254 | CodeMirror.commands.findPrev = function(cm) {doSearch(cm, true);};
255 | CodeMirror.commands.clearSearch = clearSearch;
256 | CodeMirror.commands.replace = replace;
257 | CodeMirror.commands.replaceAll = function(cm) {replace(cm, true);};
258 | });
259 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/CodeMirror/codemirror.css:
--------------------------------------------------------------------------------
1 | /* BASICS */
2 |
3 | .CodeMirror {
4 | /* Set height, width, borders, and global font properties here */
5 | font-family: monospace;
6 | height: 300px;
7 | color: black;
8 | direction: ltr;
9 | }
10 |
11 | /* PADDING */
12 |
13 | .CodeMirror-lines {
14 | padding: 4px 0; /* Vertical padding around content */
15 | }
16 | .CodeMirror pre {
17 | padding: 0 4px; /* Horizontal padding of content */
18 | }
19 |
20 | .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
21 | background-color: white; /* The little square between H and V scrollbars */
22 | }
23 |
24 | /* GUTTER */
25 |
26 | .CodeMirror-gutters {
27 | border-right: 1px solid #ddd;
28 | background-color: #f7f7f7;
29 | white-space: nowrap;
30 | }
31 | .CodeMirror-linenumbers {}
32 | .CodeMirror-linenumber {
33 | padding: 0 3px 0 5px;
34 | min-width: 20px;
35 | text-align: right;
36 | color: #999;
37 | white-space: nowrap;
38 | }
39 |
40 | .CodeMirror-guttermarker { color: black; }
41 | .CodeMirror-guttermarker-subtle { color: #999; }
42 |
43 | /* CURSOR */
44 |
45 | .CodeMirror-cursor {
46 | border-left: 1px solid black;
47 | border-right: none;
48 | width: 0;
49 | }
50 | /* Shown when moving in bi-directional text */
51 | .CodeMirror div.CodeMirror-secondarycursor {
52 | border-left: 1px solid silver;
53 | }
54 | .cm-fat-cursor .CodeMirror-cursor {
55 | width: auto;
56 | border: 0 !important;
57 | background: #7e7;
58 | }
59 | .cm-fat-cursor div.CodeMirror-cursors {
60 | z-index: 1;
61 | }
62 | .cm-fat-cursor-mark {
63 | background-color: rgba(20, 255, 20, 0.5);
64 | -webkit-animation: blink 1.06s steps(1) infinite;
65 | -moz-animation: blink 1.06s steps(1) infinite;
66 | animation: blink 1.06s steps(1) infinite;
67 | }
68 | .cm-animate-fat-cursor {
69 | width: auto;
70 | border: 0;
71 | -webkit-animation: blink 1.06s steps(1) infinite;
72 | -moz-animation: blink 1.06s steps(1) infinite;
73 | animation: blink 1.06s steps(1) infinite;
74 | background-color: #7e7;
75 | }
76 | @-moz-keyframes blink {
77 | 0% {}
78 | 50% { background-color: transparent; }
79 | 100% {}
80 | }
81 | @-webkit-keyframes blink {
82 | 0% {}
83 | 50% { background-color: transparent; }
84 | 100% {}
85 | }
86 | @keyframes blink {
87 | 0% {}
88 | 50% { background-color: transparent; }
89 | 100% {}
90 | }
91 |
92 | /* Can style cursor different in overwrite (non-insert) mode */
93 | .CodeMirror-overwrite .CodeMirror-cursor {}
94 |
95 | .cm-tab { display: inline-block; text-decoration: inherit; }
96 |
97 | .CodeMirror-rulers {
98 | position: absolute;
99 | left: 0; right: 0; top: -50px; bottom: -20px;
100 | overflow: hidden;
101 | }
102 | .CodeMirror-ruler {
103 | border-left: 1px solid #ccc;
104 | top: 0; bottom: 0;
105 | position: absolute;
106 | }
107 |
108 | /* DEFAULT THEME */
109 |
110 | .cm-s-default .cm-header {color: blue;}
111 | .cm-s-default .cm-quote {color: #090;}
112 | .cm-negative {color: #d44;}
113 | .cm-positive {color: #292;}
114 | .cm-header, .cm-strong {font-weight: bold;}
115 | .cm-em {font-style: italic;}
116 | .cm-link {text-decoration: underline;}
117 | .cm-strikethrough {text-decoration: line-through;}
118 |
119 | .cm-s-default .cm-keyword {color: #708;}
120 | .cm-s-default .cm-atom {color: #219;}
121 | .cm-s-default .cm-number {color: #164;}
122 | .cm-s-default .cm-def {color: #00f;}
123 | .cm-s-default .cm-variable,
124 | .cm-s-default .cm-punctuation,
125 | .cm-s-default .cm-property,
126 | .cm-s-default .cm-operator {}
127 | .cm-s-default .cm-variable-2 {color: #05a;}
128 | .cm-s-default .cm-variable-3, .cm-s-default .cm-type {color: #085;}
129 | .cm-s-default .cm-comment {color: #a50;}
130 | .cm-s-default .cm-string {color: #a11;}
131 | .cm-s-default .cm-string-2 {color: #f50;}
132 | .cm-s-default .cm-meta {color: #555;}
133 | .cm-s-default .cm-qualifier {color: #555;}
134 | .cm-s-default .cm-builtin {color: #30a;}
135 | .cm-s-default .cm-bracket {color: #997;}
136 | .cm-s-default .cm-tag {color: #170;}
137 | .cm-s-default .cm-attribute {color: #00c;}
138 | .cm-s-default .cm-hr {color: #999;}
139 | .cm-s-default .cm-link {color: #00c;}
140 |
141 | .cm-s-default .cm-error {color: #f00;}
142 | .cm-invalidchar {color: #f00;}
143 |
144 | .CodeMirror-composing { border-bottom: 2px solid; }
145 |
146 | /* Default styles for common addons */
147 |
148 | div.CodeMirror span.CodeMirror-matchingbracket {color: #0b0;}
149 | div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #a22;}
150 | .CodeMirror-matchingtag { background: rgba(255, 150, 0, .3); }
151 | .CodeMirror-activeline-background {background: #e8f2ff;}
152 |
153 | /* STOP */
154 |
155 | /* The rest of this file contains styles related to the mechanics of
156 | the editor. You probably shouldn't touch them. */
157 |
158 | .CodeMirror {
159 | position: relative;
160 | overflow: hidden;
161 | background: white;
162 | }
163 |
164 | .CodeMirror-scroll {
165 | overflow: scroll !important; /* Things will break if this is overridden */
166 | /* 30px is the magic margin used to hide the element's real scrollbars */
167 | /* See overflow: hidden in .CodeMirror */
168 | margin-bottom: -30px; margin-right: -30px;
169 | padding-bottom: 30px;
170 | height: 100%;
171 | outline: none; /* Prevent dragging from highlighting the element */
172 | position: relative;
173 | }
174 | .CodeMirror-sizer {
175 | position: relative;
176 | border-right: 30px solid transparent;
177 | }
178 |
179 | /* The fake, visible scrollbars. Used to force redraw during scrolling
180 | before actual scrolling happens, thus preventing shaking and
181 | flickering artifacts. */
182 | .CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler, .CodeMirror-gutter-filler {
183 | position: absolute;
184 | z-index: 6;
185 | display: none;
186 | }
187 | .CodeMirror-vscrollbar {
188 | right: 0; top: 0;
189 | overflow-x: hidden;
190 | overflow-y: scroll;
191 | }
192 | .CodeMirror-hscrollbar {
193 | bottom: 0; left: 0;
194 | overflow-y: hidden;
195 | overflow-x: scroll;
196 | }
197 | .CodeMirror-scrollbar-filler {
198 | right: 0; bottom: 0;
199 | }
200 | .CodeMirror-gutter-filler {
201 | left: 0; bottom: 0;
202 | }
203 |
204 | .CodeMirror-gutters {
205 | position: absolute; left: 0; top: 0;
206 | min-height: 100%;
207 | z-index: 3;
208 | }
209 | .CodeMirror-gutter {
210 | white-space: normal;
211 | height: 100%;
212 | display: inline-block;
213 | vertical-align: top;
214 | margin-bottom: -30px;
215 | }
216 | .CodeMirror-gutter-wrapper {
217 | position: absolute;
218 | z-index: 4;
219 | background: none !important;
220 | border: none !important;
221 | }
222 | .CodeMirror-gutter-background {
223 | position: absolute;
224 | top: 0; bottom: 0;
225 | z-index: 4;
226 | }
227 | .CodeMirror-gutter-elt {
228 | position: absolute;
229 | cursor: default;
230 | z-index: 4;
231 | }
232 | .CodeMirror-gutter-wrapper ::selection { background-color: transparent }
233 | .CodeMirror-gutter-wrapper ::-moz-selection { background-color: transparent }
234 |
235 | .CodeMirror-lines {
236 | cursor: text;
237 | min-height: 1px; /* prevents collapsing before first draw */
238 | }
239 | .CodeMirror pre {
240 | /* Reset some styles that the rest of the page might have set */
241 | -moz-border-radius: 0; -webkit-border-radius: 0; border-radius: 0;
242 | border-width: 0;
243 | background: transparent;
244 | font-family: inherit;
245 | font-size: inherit;
246 | margin: 0;
247 | white-space: pre;
248 | word-wrap: normal;
249 | line-height: inherit;
250 | color: inherit;
251 | z-index: 2;
252 | position: relative;
253 | overflow: visible;
254 | -webkit-tap-highlight-color: transparent;
255 | -webkit-font-variant-ligatures: contextual;
256 | font-variant-ligatures: contextual;
257 | }
258 | .CodeMirror-wrap pre {
259 | word-wrap: break-word;
260 | white-space: pre-wrap;
261 | word-break: normal;
262 | }
263 |
264 | .CodeMirror-linebackground {
265 | position: absolute;
266 | left: 0; right: 0; top: 0; bottom: 0;
267 | z-index: 0;
268 | }
269 |
270 | .CodeMirror-linewidget {
271 | position: relative;
272 | z-index: 2;
273 | padding: 0.1px; /* Force widget margins to stay inside of the container */
274 | }
275 |
276 | .CodeMirror-widget {}
277 |
278 | .CodeMirror-rtl pre { direction: rtl; }
279 |
280 | .CodeMirror-code {
281 | outline: none;
282 | }
283 |
284 | /* Force content-box sizing for the elements where we expect it */
285 | .CodeMirror-scroll,
286 | .CodeMirror-sizer,
287 | .CodeMirror-gutter,
288 | .CodeMirror-gutters,
289 | .CodeMirror-linenumber {
290 | -moz-box-sizing: content-box;
291 | box-sizing: content-box;
292 | }
293 |
294 | .CodeMirror-measure {
295 | position: absolute;
296 | width: 100%;
297 | height: 0;
298 | overflow: hidden;
299 | visibility: hidden;
300 | }
301 |
302 | .CodeMirror-cursor {
303 | position: absolute;
304 | pointer-events: none;
305 | }
306 | .CodeMirror-measure pre { position: static; }
307 |
308 | div.CodeMirror-cursors {
309 | visibility: hidden;
310 | position: relative;
311 | z-index: 3;
312 | }
313 | div.CodeMirror-dragcursors {
314 | visibility: visible;
315 | }
316 |
317 | .CodeMirror-focused div.CodeMirror-cursors {
318 | visibility: visible;
319 | }
320 |
321 | .CodeMirror-selected { background: #d9d9d9; }
322 | .CodeMirror-focused .CodeMirror-selected { background: #d7d4f0; }
323 | .CodeMirror-crosshair { cursor: crosshair; }
324 | .CodeMirror-line::selection, .CodeMirror-line > span::selection, .CodeMirror-line > span > span::selection { background: #d7d4f0; }
325 | .CodeMirror-line::-moz-selection, .CodeMirror-line > span::-moz-selection, .CodeMirror-line > span > span::-moz-selection { background: #d7d4f0; }
326 |
327 | .cm-searching {
328 | background-color: #ffa;
329 | background-color: rgba(255, 255, 0, .4);
330 | }
331 |
332 | /* Used to force a border model for a node */
333 | .cm-force-border { padding-right: .1px; }
334 |
335 | @media print {
336 | /* Hide the cursor when printing */
337 | .CodeMirror div.CodeMirror-cursors {
338 | visibility: hidden;
339 | }
340 | }
341 |
342 | /* See issue #2901 */
343 | .cm-tab-wrap-hack:after { content: ''; }
344 |
345 | /* Help users use markselection to safely style text background */
346 | span.CodeMirror-selectedtext { background: none; }
347 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/editor.css:
--------------------------------------------------------------------------------
1 | :root {
2 | --color-main-bg: #272a2e;
3 | --color-primary: #e86c8a;
4 | --color-green: #77e26a;
5 | --color-font-primary: #eeeff1;
6 | --color-font-secondary: #87888a;
7 | --font-family-primary: -apple-system, Helvetica, Arial, Verdana, sans-serif;
8 | --font-family-editor: Monaco, monospace;
9 | --transition: 250ms linear;
10 | --disabled-opacity: 0.35;
11 | --editor-activeline-bg: rgba(0, 0, 0, 0.30);
12 | --editor-selected-bg: rgba(150, 195, 237, 0.15); /* #96c3ed / 25% */
13 | --editor-atom: var(--color-green);
14 | --editor-comment: #68727e;
15 | --editor-def: #efc371;
16 | --editor-default: #cfd0d2;
17 | --editor-keyword: #96c3ed;
18 | --editor-number: var(--editor-atom);
19 | --editor-operator: #8c99a7;
20 | --editor-property: var(--color-primary);
21 | --editor-string: #f5eea2;
22 | --editor-string-2: #cdabff;
23 | --editor-error: #ff0000;
24 | --editor-cursor: var(--color-font-primary);
25 | --editor-matchingbracket: var(--editor-atom);
26 | --editor-nonmatchingbracket: var(--editor-error);
27 | }
28 |
29 | *,
30 | *::before,
31 | *::after {
32 | box-sizing: border-box;
33 | }
34 |
35 | html {
36 | height: 100vh;
37 | overflow: hidden;
38 | }
39 |
40 | body {
41 | background-color: var(--color-main-bg);
42 | color: var(--color-font-secondary);
43 | display: flex;
44 | flex-direction: column;
45 | font: 400 11px/16px var(--font-family-primary);
46 | height: 100%;
47 | margin: 0;
48 | max-height: 100%;
49 | -webkit-font-smoothing: antialiased;
50 | }
51 |
52 | /* prevent overscroll */
53 | body {
54 | left: 0;
55 | position: fixed;
56 | top: 0;
57 | width: 100%;
58 | }
59 |
60 | header {
61 | align-items: center;
62 | display: flex;
63 | padding: 7px 16px;
64 | -webkit-user-select: none;
65 | }
66 |
67 | .title {
68 | flex: 1;
69 | }
70 |
71 | .title span:not(#version) {
72 | color: var(--color-font-primary);
73 | font-size: 13px;
74 | font-weight: 900;
75 | letter-spacing: -0.50px;
76 | }
77 |
78 | .icon {
79 | cursor: pointer;
80 | height: 18px;
81 | width: 18px;
82 | }
83 |
84 | #info {
85 | margin-left: 24px;
86 | margin-right: 24px;
87 | }
88 |
89 | svg {
90 | fill: var(--color-font-secondary);
91 | height: 100%;
92 | transition: fill var(--transition);
93 | width: auto;
94 | }
95 |
96 | .icon:hover svg {
97 | fill: var(--color-font-primary);
98 | }
99 |
100 | body:not(.disabled) #toggle svg {
101 | fill: var(--color-green);
102 | }
103 |
104 | main {
105 | display: flex;
106 | flex: 1;
107 | flex-direction: column;
108 | }
109 |
110 | footer {
111 | align-items: center;
112 | display: flex;
113 | justify-content: flex-end;
114 | padding: 2px 16px;
115 | -webkit-user-select: none;
116 | }
117 |
118 | #status {
119 | margin-right: auto;
120 | }
121 |
122 | button {
123 | background-color: transparent;
124 | border: none;
125 | border-radius: 3px;
126 | color: var(--color-font-primary);
127 | cursor: pointer;
128 | font-weight: 700;
129 | margin: 0;
130 | padding: 7.5px 0;
131 | text-transform: uppercase;
132 | }
133 |
134 | button:hover {
135 | text-decoration: underline;
136 | }
137 |
138 | button[disabled] {
139 | opacity: var(--disabled-opacity);
140 | pointer-events: none;
141 | }
142 |
143 | #save {
144 | color: var(--color-primary);
145 | margin-left: 24px;
146 | padding-right: 0px;
147 | }
148 |
149 | .CodeMirror {
150 | background-color: var(--color-main-bg);
151 | color: #cfd0d2;
152 | font: 400 12px/1.4em var(--font-family-editor);
153 | height: 100%;
154 | }
155 |
156 | .CodeMirror-gutters {
157 | background-color: var(--color-main-bg);
158 | border-right: 0px;
159 | }
160 |
161 | .CodeMirror-activeline-background,
162 | .CodeMirror-activeline-gutter {
163 | background-color: var(--editor-activeline-bg);
164 | }
165 |
166 | .CodeMirror-linenumber {
167 | color: var(--color-font-primary);
168 | font-size: 11px;
169 | opacity: 0.25;
170 | }
171 |
172 | .CodeMirror-activeline .CodeMirror-linenumber {
173 | opacity: 0.50;
174 | }
175 |
176 | .CodeMirror-cursor {
177 | border-left: 2px solid var(--editor-cursor);
178 | }
179 |
180 | .CodeMirror-hints {
181 | background-color: rgba(27, 29, 32, 0.95);
182 | border-color: rgb(27, 29, 32);
183 | font-family: var(--font-family-editor);
184 | font-size: 11px;
185 | }
186 |
187 | .CodeMirror-hint {
188 | color: var(--color-font-secondary);
189 | }
190 |
191 | li.CodeMirror-hint-active {
192 | background-color: var(--color-primary);
193 | color: var(--color-font-primary);
194 | }
195 |
196 | .cm-s-default .CodeMirror-selected {
197 | background-color: var(--editor-selected-bg);
198 | }
199 |
200 | div.CodeMirror span.CodeMirror-matchingbracket {
201 | color: var(--editor-default);
202 | border-bottom: 2px solid var(--editor-matchingbracket);
203 | }
204 |
205 | div.CodeMirror span.CodeMirror-nonmatchingbracket {
206 | color: var(--editor-nonmatchingbracket);
207 | }
208 |
209 | .CodeMirror .CodeMirror-placeholder,
210 | .cm-s-default .cm-comment {
211 | color: var(--editor-comment);
212 | }
213 |
214 | .cm-s-default .cm-keyword {
215 | color: var(--editor-keyword);
216 | }
217 |
218 | .cm-s-default .cm-def {
219 | color: var(--editor-def);
220 | }
221 |
222 | .cm-s-default .cm-variable,
223 | .cm-s-default .cm-variable-2 {
224 | color: inherit;
225 | }
226 |
227 | .cm-s-default .cm-operator {
228 | color: var(--editor-operator);
229 | }
230 |
231 | .cm-s-default .cm-property {
232 | color: var(--editor-property);
233 | }
234 |
235 | .cm-s-default .cm-string {
236 | color: var(--editor-string);
237 | }
238 |
239 | .cm-s-default .cm-string-2 {
240 | color: var(--editor-string-2);
241 | }
242 |
243 | .cm-s-default .cm-number {
244 | color: var(--editor-number);
245 | }
246 |
247 | .cm-s-default .cm-atom {
248 | color: var(--editor-atom);
249 | }
250 |
251 | .cm-s-default .cm-error {
252 | border-bottom: 2px solid var(--editor-error);
253 | color: var(--editor-default);
254 | }
--------------------------------------------------------------------------------
/InjectJS Extension/editor/editor.js:
--------------------------------------------------------------------------------
1 | var ___userscripts = {
2 | cursor: "auto",
3 | editor: null,
4 | savedCode: null,
5 | sessionCode: null,
6 | toggleOff: null,
7 | discardButton: document.getElementById("discard"),
8 | downloadButton: document.getElementById("download"),
9 | editorElement: document.getElementById("code"),
10 | infoButton: document.getElementById("info"),
11 | saveButton: document.getElementById("save"),
12 | statusElement: document.getElementById("status"),
13 | toggleButton: document.getElementById("toggle"),
14 | getLanguageCode: function(langCode) {
15 | langCode = langCode.includes("-") ? langCode.split("-")[0] : langCode;
16 | langCode = !(langCode in ___strings) ? "en" : langCode;
17 | return "en";
18 | },
19 | toLocalizedString: function(str) {
20 | var langCode = document.body.getAttribute("lang");
21 | return ___strings[langCode][str];
22 | },
23 | setStatusText: function(str, isModificationDate = false) {
24 | if (isModificationDate) {
25 | str = this.toLocalizedString("modification_date") + " " + str;
26 | }
27 | this.statusElement.innerHTML = str;
28 | },
29 | getInfo: function() {
30 | window.webkit.messageHandlers.getInfo.postMessage("");
31 | },
32 | downloadScript: function() {
33 | window.webkit.messageHandlers.downloadScript.postMessage("");
34 | },
35 | toggle: function() {
36 | if (___userscripts.toggleOff === true) {
37 | ___userscripts.toggleOff = false;
38 | document.body.classList.remove("disabled");
39 | window.webkit.messageHandlers.setStatus.postMessage(false);
40 | if (___userscripts.savedCode != null) {
41 | window.webkit.messageHandlers.setModificationDate.postMessage("");
42 | } else {
43 | ___userscripts.setStatusText(___userscripts.toLocalizedString("status_ready"))
44 | }
45 | } else {
46 | ___userscripts.toggleOff = true;
47 | document.body.classList.add("disabled");
48 | ___userscripts.setStatusText(___userscripts.toLocalizedString("status_disabled"));
49 | window.webkit.messageHandlers.setStatus.postMessage(true);
50 | }
51 | },
52 | enableButtons: function() {
53 | this.saveButton.removeAttribute("disabled");
54 | this.discardButton.removeAttribute("disabled");
55 | },
56 | disableButtons: function() {
57 | this.saveButton.setAttribute("disabled", true);
58 | this.discardButton.setAttribute("disabled", true);
59 | },
60 | discard: function() {
61 | ___userscripts.editor.setValue(___userscripts.savedCode);
62 | ___userscripts.disableButtons();
63 | ___userscripts.editor.focus();
64 | },
65 | saveTry: function() {
66 | if (!___userscripts.saveButton.disabled) {
67 | var code = ___userscripts.editor.getValue();
68 | window.webkit.messageHandlers.saveCode.postMessage(code);
69 | ___userscripts.disableButtons();
70 | ___userscripts.setStatusText(___userscripts.toLocalizedString("status_saving"));
71 | }
72 | },
73 | saveSucceed: function(newlySavedCode) {
74 | this.savedCode = unescape(newlySavedCode);
75 | this.sessionCode = "";
76 | this.setStatusText(this.toLocalizedString("status_save_succeed"));
77 | },
78 | saveFail: function() {
79 | this.setStatusText(this.toLocalizedString("status_save_fail"));
80 | this.enableButtons();
81 | },
82 | mouseOverListen: function(e) {
83 | var sourceElement = e.srcElement;
84 | var cursorValue = getComputedStyle(sourceElement).cursor;
85 | if (cursorValue != this.currentCursor) {
86 | this.currentCursor = cursorValue;
87 | window.webkit.messageHandlers.setCursor.postMessage(cursorValue);
88 | }
89 | },
90 | editorOnChange: function(e, c) {
91 | var inputAction = c.origin;
92 |
93 | if (inputAction !== "setValue") {
94 | ___userscripts.sessionCode = e.getValue();
95 | ___userscripts.enableButtons();
96 | }
97 |
98 | if (inputAction === "undo" || inputAction === "redo") {
99 | if (___userscripts.sessionCode.localeCompare(___userscripts.savedCode) === 0) {
100 | ___userscripts.disableButtons();
101 | }
102 | }
103 | },
104 | editorOnKeydown: function(cm, e) {
105 | var currentLinePosition = cm.getCursor()["ch"];
106 | if (!cm.state.completionActive && e.metaKey === false && e.keyCode >= 65 && e.keyCode <= 90 && currentLinePosition != 0 && !(e.keyCode == 81 && e.ctrlKey)) {
107 | cm.showHint({completeSingle: false});
108 | }
109 | },
110 | startEditor: function() {
111 | this.editor = CodeMirror.fromTextArea(this.editorElement, {
112 | autoCloseBrackets: true,
113 | extraKeys: {
114 | "Ctrl-Space": "autocomplete",
115 | "Cmd-S": function() {
116 | ___userscripts.saveTry();
117 | },
118 | "Cmd-/": "toggleComment",
119 | "Ctrl-Q": function(cm) {
120 | cm.foldCode(cm.getCursor());
121 | },
122 | Tab: function(cm) {
123 | var s = Array(cm.getOption("indentUnit") + 1).join(" ");
124 | cm.replaceSelection(s);
125 | }
126 | },
127 | hintOptions: {
128 | useGlobalScope: true
129 | },
130 | indentUnit: 2,
131 | lineNumbers: true,
132 | lineWrapping: true,
133 | matchBrackets: true,
134 | mode: "javascript",
135 | smartIndent: true,
136 | styleActiveLine: true,
137 | tabSize: 2,
138 | foldGutter: true,
139 | gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"]
140 | });
141 |
142 | //add event listeners for the editor
143 | this.editor.on("change", this.editorOnChange);
144 | this.editor.on("keydown", this.editorOnKeydown);
145 |
146 | if (this.savedCode != null) {
147 | this.editor.setValue(this.savedCode);
148 | }
149 | //focus the editor
150 | this.editor.focus();
151 |
152 | //tell VC that editor is ready
153 | window.webkit.messageHandlers.webViewReady.postMessage("");
154 |
155 | },
156 | init: function(langCode, version, toggle, code) {
157 | //set the language code on the body element
158 | document.body.setAttribute("lang", this.getLanguageCode(langCode));
159 |
160 | //set the version number in the version element
161 | document.getElementById("version").innerHTML = version;
162 |
163 | //set toggle status
164 | if (JSON.parse(toggle) === true) {
165 | this.toggleOff = true;
166 | document.body.classList.add("disabled");
167 | this.setStatusText(___userscripts.toLocalizedString("status_disabled"))
168 | } else {
169 | this.toggleOff = false;
170 | this.setStatusText(___userscripts.toLocalizedString("status_ready"))
171 | }
172 |
173 | //set the saved code
174 | if (code != null) {
175 | this.savedCode = unescape(code);
176 | }
177 |
178 | //load the init text for the various DOM elements
179 | this.editorElement.placeholder = this.toLocalizedString("editor_placeholder");
180 | this.saveButton.innerHTML = this.toLocalizedString("button_save");
181 | this.discardButton.innerHTML = this.toLocalizedString("button_discard");
182 |
183 | //add event listeners
184 | this.downloadButton.addEventListener("click", this.downloadScript);
185 | this.infoButton.addEventListener("click", this.getInfo);
186 | this.toggleButton.addEventListener("click", this.toggle);
187 | this.discardButton.addEventListener("click", this.discard);
188 | this.saveButton.addEventListener("click", this.saveTry);
189 | document.addEventListener("mouseover", this.mouseOverListen);
190 |
191 | //start the editor
192 | this.startEditor();
193 |
194 | },
195 | windowLoad: function() {
196 | var code = `console.log('foo');`;
197 | var tog = true;
198 | this.init("en-GB", "v1.4.0", tog, code);
199 | }
200 | };
201 |
202 | //window.onload = ___userscripts.windowLoad();
203 |
--------------------------------------------------------------------------------
/InjectJS Extension/editor/localize.js:
--------------------------------------------------------------------------------
1 | const ___strings = {
2 | "en": {
3 | "button_save": "Save",
4 | "button_discard": "Discard",
5 | "editor_placeholder": "//Code input here gets injected into every website you visit...",
6 | "modification_date": "Last modified on",
7 | "status_disabled": "Code injection disabled, click the power button to enable...",
8 | "status_ready": "Ready for code...",
9 | "status_saving": "Saving changes...",
10 | "status_save_succeed": "All changes saved...",
11 | "status_save_fail": "Failed to save changes..."
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/InjectJS Extension/script.js:
--------------------------------------------------------------------------------
1 | function injectCode(code) {
2 | return Function(code)();
3 | }
4 |
5 | function downloadScript(code) {
6 | var el = document.createElement("a");
7 | el.setAttribute("href", "data:text/plain;charset=utf-8," + encodeURIComponent(code));
8 | el.setAttribute("download", "userscript.js");
9 | el.style.display = "none";
10 | document.body.appendChild(el);
11 | el.click();
12 | document.body.removeChild(el);
13 | }
14 |
15 | function handleMessage(event) {
16 | if (event.name === "SEND_SAVED_CODE") {
17 | injectCode(unescape(event.message.code));
18 | }
19 | if (event.name === "DOWNLOAD_SCRIPT") {
20 | if (window.top === window) {
21 | downloadScript(event.message.code)
22 | }
23 | }
24 | }
25 |
26 | if (window.top === window) {
27 | safari.extension.dispatchMessage("REQUEST_SAVED_CODE");
28 | }
29 |
30 | safari.self.addEventListener("message", handleMessage);
31 |
--------------------------------------------------------------------------------
/InjectJS.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 50;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 4A5E155C246376EE00038A0C /* InjectJS.entitlements in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E155B246376EE00038A0C /* InjectJS.entitlements */; };
11 | 4A5E155E246376EE00038A0C /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5E155D246376EE00038A0C /* AppDelegate.swift */; };
12 | 4A5E1561246376EE00038A0C /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E155F246376EE00038A0C /* Main.storyboard */; };
13 | 4A5E1563246376EE00038A0C /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5E1562246376EE00038A0C /* ViewController.swift */; };
14 | 4A5E1565246376EF00038A0C /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E1564246376EF00038A0C /* Assets.xcassets */; };
15 | 4A5E156C246376EF00038A0C /* InjectJS Extension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = 4A5E156B246376EF00038A0C /* InjectJS Extension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
16 | 4A5E1571246376EF00038A0C /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4A5E1570246376EF00038A0C /* Cocoa.framework */; };
17 | 4A5E1574246376EF00038A0C /* SafariExtensionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5E1573246376EF00038A0C /* SafariExtensionHandler.swift */; };
18 | 4A5E1576246376EF00038A0C /* SafariExtensionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4A5E1575246376EF00038A0C /* SafariExtensionViewController.swift */; };
19 | 4A5E1579246376EF00038A0C /* SafariExtensionViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E1577246376EF00038A0C /* SafariExtensionViewController.xib */; };
20 | 4A5E157C246376EF00038A0C /* script.js in Resources */ = {isa = PBXBuildFile; fileRef = 4A5E157B246376EF00038A0C /* script.js */; };
21 | 4ADFD0BE2463792500D8188A /* editor in Resources */ = {isa = PBXBuildFile; fileRef = 4ADFD0BC2463792500D8188A /* editor */; };
22 | 4ADFD0BF2463792500D8188A /* editor.html in Resources */ = {isa = PBXBuildFile; fileRef = 4ADFD0BD2463792500D8188A /* editor.html */; };
23 | 4ADFD0C12463796D00D8188A /* ToolbarItemIcon.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4ADFD0C02463796D00D8188A /* ToolbarItemIcon.pdf */; };
24 | /* End PBXBuildFile section */
25 |
26 | /* Begin PBXContainerItemProxy section */
27 | 4A5E156D246376EF00038A0C /* PBXContainerItemProxy */ = {
28 | isa = PBXContainerItemProxy;
29 | containerPortal = 4A5E1550246376EE00038A0C /* Project object */;
30 | proxyType = 1;
31 | remoteGlobalIDString = 4A5E156A246376EF00038A0C;
32 | remoteInfo = "InjectJS Extension";
33 | };
34 | /* End PBXContainerItemProxy section */
35 |
36 | /* Begin PBXCopyFilesBuildPhase section */
37 | 4A5E1585246376EF00038A0C /* Embed App Extensions */ = {
38 | isa = PBXCopyFilesBuildPhase;
39 | buildActionMask = 2147483647;
40 | dstPath = "";
41 | dstSubfolderSpec = 13;
42 | files = (
43 | 4A5E156C246376EF00038A0C /* InjectJS Extension.appex in Embed App Extensions */,
44 | );
45 | name = "Embed App Extensions";
46 | runOnlyForDeploymentPostprocessing = 0;
47 | };
48 | /* End PBXCopyFilesBuildPhase section */
49 |
50 | /* Begin PBXFileReference section */
51 | 4A5E1558246376EE00038A0C /* InjectJS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = InjectJS.app; sourceTree = BUILT_PRODUCTS_DIR; };
52 | 4A5E155B246376EE00038A0C /* InjectJS.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = InjectJS.entitlements; sourceTree = ""; };
53 | 4A5E155D246376EE00038A0C /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
54 | 4A5E1560246376EE00038A0C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
55 | 4A5E1562246376EE00038A0C /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
56 | 4A5E1564246376EF00038A0C /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
57 | 4A5E1566246376EF00038A0C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
58 | 4A5E156B246376EF00038A0C /* InjectJS Extension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = "InjectJS Extension.appex"; sourceTree = BUILT_PRODUCTS_DIR; };
59 | 4A5E1570246376EF00038A0C /* Cocoa.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Cocoa.framework; path = System/Library/Frameworks/Cocoa.framework; sourceTree = SDKROOT; };
60 | 4A5E1573246376EF00038A0C /* SafariExtensionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionHandler.swift; sourceTree = ""; };
61 | 4A5E1575246376EF00038A0C /* SafariExtensionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SafariExtensionViewController.swift; sourceTree = ""; };
62 | 4A5E1578246376EF00038A0C /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/SafariExtensionViewController.xib; sourceTree = ""; };
63 | 4A5E157A246376EF00038A0C /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
64 | 4A5E157B246376EF00038A0C /* script.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = script.js; sourceTree = ""; };
65 | 4A5E157F246376EF00038A0C /* InjectJS_Extension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = InjectJS_Extension.entitlements; sourceTree = ""; };
66 | 4ADFD0BC2463792500D8188A /* editor */ = {isa = PBXFileReference; lastKnownFileType = folder; path = editor; sourceTree = ""; };
67 | 4ADFD0BD2463792500D8188A /* editor.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = editor.html; sourceTree = ""; };
68 | 4ADFD0C02463796D00D8188A /* ToolbarItemIcon.pdf */ = {isa = PBXFileReference; lastKnownFileType = image.pdf; path = ToolbarItemIcon.pdf; sourceTree = ""; };
69 | /* End PBXFileReference section */
70 |
71 | /* Begin PBXFrameworksBuildPhase section */
72 | 4A5E1555246376EE00038A0C /* Frameworks */ = {
73 | isa = PBXFrameworksBuildPhase;
74 | buildActionMask = 2147483647;
75 | files = (
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | 4A5E1568246376EF00038A0C /* Frameworks */ = {
80 | isa = PBXFrameworksBuildPhase;
81 | buildActionMask = 2147483647;
82 | files = (
83 | 4A5E1571246376EF00038A0C /* Cocoa.framework in Frameworks */,
84 | );
85 | runOnlyForDeploymentPostprocessing = 0;
86 | };
87 | /* End PBXFrameworksBuildPhase section */
88 |
89 | /* Begin PBXGroup section */
90 | 4A5E154F246376EE00038A0C = {
91 | isa = PBXGroup;
92 | children = (
93 | 4A5E155A246376EE00038A0C /* InjectJS */,
94 | 4A5E1572246376EF00038A0C /* InjectJS Extension */,
95 | 4A5E156F246376EF00038A0C /* Frameworks */,
96 | 4A5E1559246376EE00038A0C /* Products */,
97 | );
98 | sourceTree = "";
99 | };
100 | 4A5E1559246376EE00038A0C /* Products */ = {
101 | isa = PBXGroup;
102 | children = (
103 | 4A5E1558246376EE00038A0C /* InjectJS.app */,
104 | 4A5E156B246376EF00038A0C /* InjectJS Extension.appex */,
105 | );
106 | name = Products;
107 | sourceTree = "";
108 | };
109 | 4A5E155A246376EE00038A0C /* InjectJS */ = {
110 | isa = PBXGroup;
111 | children = (
112 | 4A5E155B246376EE00038A0C /* InjectJS.entitlements */,
113 | 4A5E155D246376EE00038A0C /* AppDelegate.swift */,
114 | 4A5E155F246376EE00038A0C /* Main.storyboard */,
115 | 4A5E1562246376EE00038A0C /* ViewController.swift */,
116 | 4A5E1564246376EF00038A0C /* Assets.xcassets */,
117 | 4A5E1566246376EF00038A0C /* Info.plist */,
118 | );
119 | path = InjectJS;
120 | sourceTree = "";
121 | };
122 | 4A5E156F246376EF00038A0C /* Frameworks */ = {
123 | isa = PBXGroup;
124 | children = (
125 | 4A5E1570246376EF00038A0C /* Cocoa.framework */,
126 | );
127 | name = Frameworks;
128 | sourceTree = "";
129 | };
130 | 4A5E1572246376EF00038A0C /* InjectJS Extension */ = {
131 | isa = PBXGroup;
132 | children = (
133 | 4A5E1573246376EF00038A0C /* SafariExtensionHandler.swift */,
134 | 4A5E1575246376EF00038A0C /* SafariExtensionViewController.swift */,
135 | 4A5E1577246376EF00038A0C /* SafariExtensionViewController.xib */,
136 | 4A5E157A246376EF00038A0C /* Info.plist */,
137 | 4A5E157B246376EF00038A0C /* script.js */,
138 | 4ADFD0C02463796D00D8188A /* ToolbarItemIcon.pdf */,
139 | 4ADFD0BC2463792500D8188A /* editor */,
140 | 4ADFD0BD2463792500D8188A /* editor.html */,
141 | 4A5E157F246376EF00038A0C /* InjectJS_Extension.entitlements */,
142 | );
143 | path = "InjectJS Extension";
144 | sourceTree = "";
145 | };
146 | /* End PBXGroup section */
147 |
148 | /* Begin PBXNativeTarget section */
149 | 4A5E1557246376EE00038A0C /* InjectJS */ = {
150 | isa = PBXNativeTarget;
151 | buildConfigurationList = 4A5E1586246376EF00038A0C /* Build configuration list for PBXNativeTarget "InjectJS" */;
152 | buildPhases = (
153 | 4A5E1554246376EE00038A0C /* Sources */,
154 | 4A5E1555246376EE00038A0C /* Frameworks */,
155 | 4A5E1556246376EE00038A0C /* Resources */,
156 | 4A5E1585246376EF00038A0C /* Embed App Extensions */,
157 | );
158 | buildRules = (
159 | );
160 | dependencies = (
161 | 4A5E156E246376EF00038A0C /* PBXTargetDependency */,
162 | );
163 | name = InjectJS;
164 | productName = InjectJS;
165 | productReference = 4A5E1558246376EE00038A0C /* InjectJS.app */;
166 | productType = "com.apple.product-type.application";
167 | };
168 | 4A5E156A246376EF00038A0C /* InjectJS Extension */ = {
169 | isa = PBXNativeTarget;
170 | buildConfigurationList = 4A5E1582246376EF00038A0C /* Build configuration list for PBXNativeTarget "InjectJS Extension" */;
171 | buildPhases = (
172 | 4A5E1567246376EF00038A0C /* Sources */,
173 | 4A5E1568246376EF00038A0C /* Frameworks */,
174 | 4A5E1569246376EF00038A0C /* Resources */,
175 | );
176 | buildRules = (
177 | );
178 | dependencies = (
179 | );
180 | name = "InjectJS Extension";
181 | productName = "InjectJS Extension";
182 | productReference = 4A5E156B246376EF00038A0C /* InjectJS Extension.appex */;
183 | productType = "com.apple.product-type.app-extension";
184 | };
185 | /* End PBXNativeTarget section */
186 |
187 | /* Begin PBXProject section */
188 | 4A5E1550246376EE00038A0C /* Project object */ = {
189 | isa = PBXProject;
190 | attributes = {
191 | LastSwiftUpdateCheck = 1100;
192 | LastUpgradeCheck = 1100;
193 | ORGANIZATIONNAME = "Justin Wasack";
194 | TargetAttributes = {
195 | 4A5E1557246376EE00038A0C = {
196 | CreatedOnToolsVersion = 11.0;
197 | };
198 | 4A5E156A246376EF00038A0C = {
199 | CreatedOnToolsVersion = 11.0;
200 | };
201 | };
202 | };
203 | buildConfigurationList = 4A5E1553246376EE00038A0C /* Build configuration list for PBXProject "InjectJS" */;
204 | compatibilityVersion = "Xcode 9.3";
205 | developmentRegion = en;
206 | hasScannedForEncodings = 0;
207 | knownRegions = (
208 | en,
209 | Base,
210 | );
211 | mainGroup = 4A5E154F246376EE00038A0C;
212 | productRefGroup = 4A5E1559246376EE00038A0C /* Products */;
213 | projectDirPath = "";
214 | projectRoot = "";
215 | targets = (
216 | 4A5E1557246376EE00038A0C /* InjectJS */,
217 | 4A5E156A246376EF00038A0C /* InjectJS Extension */,
218 | );
219 | };
220 | /* End PBXProject section */
221 |
222 | /* Begin PBXResourcesBuildPhase section */
223 | 4A5E1556246376EE00038A0C /* Resources */ = {
224 | isa = PBXResourcesBuildPhase;
225 | buildActionMask = 2147483647;
226 | files = (
227 | 4A5E155C246376EE00038A0C /* InjectJS.entitlements in Resources */,
228 | 4A5E1565246376EF00038A0C /* Assets.xcassets in Resources */,
229 | 4A5E1561246376EE00038A0C /* Main.storyboard in Resources */,
230 | );
231 | runOnlyForDeploymentPostprocessing = 0;
232 | };
233 | 4A5E1569246376EF00038A0C /* Resources */ = {
234 | isa = PBXResourcesBuildPhase;
235 | buildActionMask = 2147483647;
236 | files = (
237 | 4ADFD0BF2463792500D8188A /* editor.html in Resources */,
238 | 4ADFD0BE2463792500D8188A /* editor in Resources */,
239 | 4A5E1579246376EF00038A0C /* SafariExtensionViewController.xib in Resources */,
240 | 4ADFD0C12463796D00D8188A /* ToolbarItemIcon.pdf in Resources */,
241 | 4A5E157C246376EF00038A0C /* script.js in Resources */,
242 | );
243 | runOnlyForDeploymentPostprocessing = 0;
244 | };
245 | /* End PBXResourcesBuildPhase section */
246 |
247 | /* Begin PBXSourcesBuildPhase section */
248 | 4A5E1554246376EE00038A0C /* Sources */ = {
249 | isa = PBXSourcesBuildPhase;
250 | buildActionMask = 2147483647;
251 | files = (
252 | 4A5E1563246376EE00038A0C /* ViewController.swift in Sources */,
253 | 4A5E155E246376EE00038A0C /* AppDelegate.swift in Sources */,
254 | );
255 | runOnlyForDeploymentPostprocessing = 0;
256 | };
257 | 4A5E1567246376EF00038A0C /* Sources */ = {
258 | isa = PBXSourcesBuildPhase;
259 | buildActionMask = 2147483647;
260 | files = (
261 | 4A5E1576246376EF00038A0C /* SafariExtensionViewController.swift in Sources */,
262 | 4A5E1574246376EF00038A0C /* SafariExtensionHandler.swift in Sources */,
263 | );
264 | runOnlyForDeploymentPostprocessing = 0;
265 | };
266 | /* End PBXSourcesBuildPhase section */
267 |
268 | /* Begin PBXTargetDependency section */
269 | 4A5E156E246376EF00038A0C /* PBXTargetDependency */ = {
270 | isa = PBXTargetDependency;
271 | target = 4A5E156A246376EF00038A0C /* InjectJS Extension */;
272 | targetProxy = 4A5E156D246376EF00038A0C /* PBXContainerItemProxy */;
273 | };
274 | /* End PBXTargetDependency section */
275 |
276 | /* Begin PBXVariantGroup section */
277 | 4A5E155F246376EE00038A0C /* Main.storyboard */ = {
278 | isa = PBXVariantGroup;
279 | children = (
280 | 4A5E1560246376EE00038A0C /* Base */,
281 | );
282 | name = Main.storyboard;
283 | sourceTree = "";
284 | };
285 | 4A5E1577246376EF00038A0C /* SafariExtensionViewController.xib */ = {
286 | isa = PBXVariantGroup;
287 | children = (
288 | 4A5E1578246376EF00038A0C /* Base */,
289 | );
290 | name = SafariExtensionViewController.xib;
291 | sourceTree = "";
292 | };
293 | /* End PBXVariantGroup section */
294 |
295 | /* Begin XCBuildConfiguration section */
296 | 4A5E1580246376EF00038A0C /* Debug */ = {
297 | isa = XCBuildConfiguration;
298 | buildSettings = {
299 | ALWAYS_SEARCH_USER_PATHS = NO;
300 | CLANG_ANALYZER_NONNULL = YES;
301 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
302 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
303 | CLANG_CXX_LIBRARY = "libc++";
304 | CLANG_ENABLE_MODULES = YES;
305 | CLANG_ENABLE_OBJC_ARC = YES;
306 | CLANG_ENABLE_OBJC_WEAK = YES;
307 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
308 | CLANG_WARN_BOOL_CONVERSION = YES;
309 | CLANG_WARN_COMMA = YES;
310 | CLANG_WARN_CONSTANT_CONVERSION = YES;
311 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
312 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
313 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
314 | CLANG_WARN_EMPTY_BODY = YES;
315 | CLANG_WARN_ENUM_CONVERSION = YES;
316 | CLANG_WARN_INFINITE_RECURSION = YES;
317 | CLANG_WARN_INT_CONVERSION = YES;
318 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
319 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
320 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
321 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
322 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
323 | CLANG_WARN_STRICT_PROTOTYPES = YES;
324 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
325 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
326 | CLANG_WARN_UNREACHABLE_CODE = YES;
327 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
328 | COPY_PHASE_STRIP = NO;
329 | DEBUG_INFORMATION_FORMAT = dwarf;
330 | ENABLE_STRICT_OBJC_MSGSEND = YES;
331 | ENABLE_TESTABILITY = YES;
332 | GCC_C_LANGUAGE_STANDARD = gnu11;
333 | GCC_DYNAMIC_NO_PIC = NO;
334 | GCC_NO_COMMON_BLOCKS = YES;
335 | GCC_OPTIMIZATION_LEVEL = 0;
336 | GCC_PREPROCESSOR_DEFINITIONS = (
337 | "DEBUG=1",
338 | "$(inherited)",
339 | );
340 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
341 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
342 | GCC_WARN_UNDECLARED_SELECTOR = YES;
343 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
344 | GCC_WARN_UNUSED_FUNCTION = YES;
345 | GCC_WARN_UNUSED_VARIABLE = YES;
346 | MACOSX_DEPLOYMENT_TARGET = 10.13;
347 | MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
348 | MTL_FAST_MATH = YES;
349 | ONLY_ACTIVE_ARCH = YES;
350 | SDKROOT = macosx;
351 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
352 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
353 | };
354 | name = Debug;
355 | };
356 | 4A5E1581246376EF00038A0C /* Release */ = {
357 | isa = XCBuildConfiguration;
358 | buildSettings = {
359 | ALWAYS_SEARCH_USER_PATHS = NO;
360 | CLANG_ANALYZER_NONNULL = YES;
361 | CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
362 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
363 | CLANG_CXX_LIBRARY = "libc++";
364 | CLANG_ENABLE_MODULES = YES;
365 | CLANG_ENABLE_OBJC_ARC = YES;
366 | CLANG_ENABLE_OBJC_WEAK = YES;
367 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
368 | CLANG_WARN_BOOL_CONVERSION = YES;
369 | CLANG_WARN_COMMA = YES;
370 | CLANG_WARN_CONSTANT_CONVERSION = YES;
371 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
372 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
373 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
374 | CLANG_WARN_EMPTY_BODY = YES;
375 | CLANG_WARN_ENUM_CONVERSION = YES;
376 | CLANG_WARN_INFINITE_RECURSION = YES;
377 | CLANG_WARN_INT_CONVERSION = YES;
378 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
379 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
380 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
381 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
382 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
383 | CLANG_WARN_STRICT_PROTOTYPES = YES;
384 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
385 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
386 | CLANG_WARN_UNREACHABLE_CODE = YES;
387 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
388 | COPY_PHASE_STRIP = NO;
389 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
390 | ENABLE_NS_ASSERTIONS = NO;
391 | ENABLE_STRICT_OBJC_MSGSEND = YES;
392 | GCC_C_LANGUAGE_STANDARD = gnu11;
393 | GCC_NO_COMMON_BLOCKS = YES;
394 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
395 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
396 | GCC_WARN_UNDECLARED_SELECTOR = YES;
397 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
398 | GCC_WARN_UNUSED_FUNCTION = YES;
399 | GCC_WARN_UNUSED_VARIABLE = YES;
400 | MACOSX_DEPLOYMENT_TARGET = 10.13;
401 | MTL_ENABLE_DEBUG_INFO = NO;
402 | MTL_FAST_MATH = YES;
403 | SDKROOT = macosx;
404 | SWIFT_COMPILATION_MODE = wholemodule;
405 | SWIFT_OPTIMIZATION_LEVEL = "-O";
406 | };
407 | name = Release;
408 | };
409 | 4A5E1583246376EF00038A0C /* Debug */ = {
410 | isa = XCBuildConfiguration;
411 | buildSettings = {
412 | CODE_SIGN_ENTITLEMENTS = "InjectJS Extension/InjectJS_Extension.entitlements";
413 | CODE_SIGN_STYLE = Automatic;
414 | DEVELOPMENT_TEAM = J74Q8V8V8N;
415 | ENABLE_HARDENED_RUNTIME = YES;
416 | INFOPLIST_FILE = "InjectJS Extension/Info.plist";
417 | LD_RUNPATH_SEARCH_PATHS = (
418 | "$(inherited)",
419 | "@executable_path/../Frameworks",
420 | "@executable_path/../../../../Frameworks",
421 | );
422 | PRODUCT_BUNDLE_IDENTIFIER = "com.injectjs.macos.InjectJS-Extension";
423 | PRODUCT_NAME = "$(TARGET_NAME)";
424 | SKIP_INSTALL = YES;
425 | SWIFT_VERSION = 5.0;
426 | };
427 | name = Debug;
428 | };
429 | 4A5E1584246376EF00038A0C /* Release */ = {
430 | isa = XCBuildConfiguration;
431 | buildSettings = {
432 | CODE_SIGN_ENTITLEMENTS = "InjectJS Extension/InjectJS_Extension.entitlements";
433 | CODE_SIGN_STYLE = Automatic;
434 | DEVELOPMENT_TEAM = J74Q8V8V8N;
435 | ENABLE_HARDENED_RUNTIME = YES;
436 | INFOPLIST_FILE = "InjectJS Extension/Info.plist";
437 | LD_RUNPATH_SEARCH_PATHS = (
438 | "$(inherited)",
439 | "@executable_path/../Frameworks",
440 | "@executable_path/../../../../Frameworks",
441 | );
442 | PRODUCT_BUNDLE_IDENTIFIER = "com.injectjs.macos.InjectJS-Extension";
443 | PRODUCT_NAME = "$(TARGET_NAME)";
444 | SKIP_INSTALL = YES;
445 | SWIFT_VERSION = 5.0;
446 | };
447 | name = Release;
448 | };
449 | 4A5E1587246376EF00038A0C /* Debug */ = {
450 | isa = XCBuildConfiguration;
451 | buildSettings = {
452 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
453 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
454 | CODE_SIGN_ENTITLEMENTS = InjectJS/InjectJS.entitlements;
455 | CODE_SIGN_STYLE = Automatic;
456 | COMBINE_HIDPI_IMAGES = YES;
457 | DEVELOPMENT_TEAM = J74Q8V8V8N;
458 | ENABLE_HARDENED_RUNTIME = YES;
459 | INFOPLIST_FILE = InjectJS/Info.plist;
460 | LD_RUNPATH_SEARCH_PATHS = (
461 | "$(inherited)",
462 | "@executable_path/../Frameworks",
463 | );
464 | PRODUCT_BUNDLE_IDENTIFIER = com.injectjs.macos;
465 | PRODUCT_NAME = "$(TARGET_NAME)";
466 | SWIFT_VERSION = 5.0;
467 | };
468 | name = Debug;
469 | };
470 | 4A5E1588246376EF00038A0C /* Release */ = {
471 | isa = XCBuildConfiguration;
472 | buildSettings = {
473 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
474 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
475 | CODE_SIGN_ENTITLEMENTS = InjectJS/InjectJS.entitlements;
476 | CODE_SIGN_STYLE = Automatic;
477 | COMBINE_HIDPI_IMAGES = YES;
478 | DEVELOPMENT_TEAM = J74Q8V8V8N;
479 | ENABLE_HARDENED_RUNTIME = YES;
480 | INFOPLIST_FILE = InjectJS/Info.plist;
481 | LD_RUNPATH_SEARCH_PATHS = (
482 | "$(inherited)",
483 | "@executable_path/../Frameworks",
484 | );
485 | PRODUCT_BUNDLE_IDENTIFIER = com.injectjs.macos;
486 | PRODUCT_NAME = "$(TARGET_NAME)";
487 | SWIFT_VERSION = 5.0;
488 | };
489 | name = Release;
490 | };
491 | /* End XCBuildConfiguration section */
492 |
493 | /* Begin XCConfigurationList section */
494 | 4A5E1553246376EE00038A0C /* Build configuration list for PBXProject "InjectJS" */ = {
495 | isa = XCConfigurationList;
496 | buildConfigurations = (
497 | 4A5E1580246376EF00038A0C /* Debug */,
498 | 4A5E1581246376EF00038A0C /* Release */,
499 | );
500 | defaultConfigurationIsVisible = 0;
501 | defaultConfigurationName = Release;
502 | };
503 | 4A5E1582246376EF00038A0C /* Build configuration list for PBXNativeTarget "InjectJS Extension" */ = {
504 | isa = XCConfigurationList;
505 | buildConfigurations = (
506 | 4A5E1583246376EF00038A0C /* Debug */,
507 | 4A5E1584246376EF00038A0C /* Release */,
508 | );
509 | defaultConfigurationIsVisible = 0;
510 | defaultConfigurationName = Release;
511 | };
512 | 4A5E1586246376EF00038A0C /* Build configuration list for PBXNativeTarget "InjectJS" */ = {
513 | isa = XCConfigurationList;
514 | buildConfigurations = (
515 | 4A5E1587246376EF00038A0C /* Debug */,
516 | 4A5E1588246376EF00038A0C /* Release */,
517 | );
518 | defaultConfigurationIsVisible = 0;
519 | defaultConfigurationName = Release;
520 | };
521 | /* End XCConfigurationList section */
522 | };
523 | rootObject = 4A5E1550246376EE00038A0C /* Project object */;
524 | }
525 |
--------------------------------------------------------------------------------
/InjectJS.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/InjectJS.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/InjectJS/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // InjectJS
4 | //
5 | // Created by Justin Wasack on 5/6/20.
6 | // Copyright © 2020 Justin Wasack. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 | func applicationDidFinishLaunching(_ aNotification: Notification) {
15 | // Insert code here to initialize your application
16 | }
17 |
18 | func applicationWillTerminate(_ aNotification: Notification) {
19 | // Insert code here to tear down your application
20 | }
21 |
22 | func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
23 | return true
24 | }
25 |
26 | }
27 |
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/1024.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/1024.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/128.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/16.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/256-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/256-1.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/256.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/32-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/32-1.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/32.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/512-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/512-1.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/512.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/64.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/InjectJS/Assets.xcassets/AppIcon.appiconset/64.png
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "32.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "32-1.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "64.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "256.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "256-1.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "512.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "512-1.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "1024.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/InjectJS/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/InjectJS/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
--------------------------------------------------------------------------------
/InjectJS/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 |
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | $(PRODUCT_BUNDLE_PACKAGE_TYPE)
19 | CFBundleShortVersionString
20 | 1.0
21 | CFBundleVersion
22 | 1
23 | LSApplicationCategoryType
24 | public.app-category.developer-tools
25 | LSMinimumSystemVersion
26 | $(MACOSX_DEPLOYMENT_TARGET)
27 | NSHumanReadableCopyright
28 | Copyright © 2020 Justin Wasack. All rights reserved.
29 | NSMainStoryboardFile
30 | Main
31 | NSPrincipalClass
32 | NSApplication
33 | NSSupportsAutomaticTermination
34 |
35 | NSSupportsSuddenTermination
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/InjectJS/InjectJS.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.files.user-selected.read-only
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/InjectJS/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // InjectJS
4 | //
5 | // Created by Justin Wasack on 5/6/20.
6 | // Copyright © 2020 Justin Wasack. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 | import SafariServices.SFSafariApplication
11 |
12 | class ViewController: NSViewController {
13 |
14 | @IBOutlet var appNameLabel: NSTextField!
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 | let appVersion = Bundle.main.infoDictionary!["CFBundleShortVersionString"] as! String
19 | self.appNameLabel.stringValue = "InjectJS - Version \(appVersion)";
20 | }
21 |
22 | @IBAction func openSafariExtensionPreferences(_ sender: AnyObject?) {
23 | SFSafariApplication.showPreferencesForExtension(withIdentifier: "com.injectjs.macos.InjectJS-Extension") { error in
24 | if let _ = error {
25 | // Insert code to inform the user that something went wrong.
26 |
27 | }
28 | }
29 | }
30 |
31 | }
32 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | How to Apply These Terms to Your New Programs
624 |
625 | If you develop a new program, and you want it to be of the greatest
626 | possible use to the public, the best way to achieve this is to make it
627 | free software which everyone can redistribute and change under these terms.
628 |
629 | To do so, attach the following notices to the program. It is safest
630 | to attach them to the start of each source file to most effectively
631 | state the exclusion of warranty; and each file should have at least
632 | the "copyright" line and a pointer to where the full notice is found.
633 |
634 |
635 | Copyright (C)
636 |
637 | This program is free software: you can redistribute it and/or modify
638 | it under the terms of the GNU General Public License as published by
639 | the Free Software Foundation, either version 3 of the License, or
640 | (at your option) any later version.
641 |
642 | This program is distributed in the hope that it will be useful,
643 | but WITHOUT ANY WARRANTY; without even the implied warranty of
644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
645 | GNU General Public License for more details.
646 |
647 | You should have received a copy of the GNU General Public License
648 | along with this program. If not, see .
649 |
650 | Also add information on how to contact you by electronic and paper mail.
651 |
652 | If the program does terminal interaction, make it output a short
653 | notice like this when it starts in an interactive mode:
654 |
655 | Copyright (C)
656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
657 | This is free software, and you are welcome to redistribute it
658 | under certain conditions; type `show c' for details.
659 |
660 | The hypothetical commands `show w' and `show c' should show the appropriate
661 | parts of the General Public License. Of course, your program's commands
662 | might be different; for a GUI interface, you would use an "about box".
663 |
664 | You should also get your employer (if you work as a programmer) or school,
665 | if any, to sign a "copyright disclaimer" for the program, if necessary.
666 | For more information on this, and how to apply and follow the GNU GPL, see
667 | .
668 |
669 | The GNU General Public License does not permit incorporating your program
670 | into proprietary programs. If your program is a subroutine library, you
671 | may consider it more useful to permit linking proprietary applications with
672 | the library. If this is what you want to do, use the GNU Lesser General
673 | Public License instead of this License. But first, please read
674 | .
675 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # InjectJS for Safari
2 |
3 | A simple, open-source, userscript editor for Safari.
4 |
5 | 
6 |
7 | ## Installation
8 |
9 | Install via [Mac App Store](https://apps.apple.com/us/app/injectjs/id1515350193) or clone the project and build with Xcode.
10 |
11 | ## Usage
12 |
13 | Using the extension is simple. You can open the editor by clicking on the the toolbar button. Any code you write will be injected into every website you visit.
14 |
15 | Here are some usage notes:
16 |
17 | - `cmd + s` to save changes to the editor
18 | - hinting is automatic, you can use the shortcut `ctrl + spacebar` to toggle hinting manually
19 | - your code is saved into `~/Library/Containers/com.injectjs.macos.InjectJS-Extension/Data/Documents/userscript.js`
20 | - this file can be edited with any code editor, however if the browser/extension is currently running, those changes won't be reflect in the include editor unless you reload the popover (right click `->` reload) - the changes **will** be injected whether or not you reload
21 | - you can click the download icon to save your script file locally, without needing to navigate to this folder
22 | - *note*, you will not be able to download the script on a blank tab
23 | - you can toggle script injection on and off by clicking the "power" icon
24 | - the code folding key command is `ctrl+q`
25 |
26 | ## Why?
27 |
28 | With the depreciation of `.safariextz` style extension in Safari 12, I wanted a way to quickly and easily create some "quality of life" userscripts. Since it's no longer possible to create and sign, even personal, `.safariextz` extensions, I needed a new way to dynamically create userscripts.
29 |
30 | There are other userscripts editors/managers for other browsers, and even good ones for Safari, but I wanted something very simple and *open-source*.
31 |
32 | ## Privacy Policy
33 | InjectJS does not collect any data from its users nor monitor activities or actions you perform within the application and extension. This means everything that you do with the application and extension is private to you and is never shared with the developers or third parties. Since there is no data collection, there is no data retention of any kind.
34 |
35 | ## License
36 |
37 | Licensed under the [GNU General Public License v3.0](/LICENSE) license for all open source applications. A commercial license is required for all commercial applications.
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/etc/App Store Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/etc/App Store Screenshot.png
--------------------------------------------------------------------------------
/etc/InjectJS-demo.mp4:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/etc/InjectJS-demo.mp4
--------------------------------------------------------------------------------
/etc/assets.sketch:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/quoid/InjectJS/468875b3b0ef2355bdcf1110d5bd4494cd6b3042/etc/assets.sketch
--------------------------------------------------------------------------------