') + ')', 'gi'); if (regex.test(text)) { found = true; var frag = document.createDocumentFragment(); var parts = text.split(regex); parts.forEach(function(part, i) { if (i % 2 === 0) { frag.appendChild(document.createTextNode(part)); } else { var span = document.createElement('span'); span.className = 'userscript-highlight'; span.textContent = part; frag.appendChild(span); } }); node.parentNode.replaceChild(frag, node); } }); } else if (node.nodeType === 1 && node.childNodes) { // element var skipTags = ['SCRIPT', 'STYLE', 'NOSCRIPT', 'TEXTAREA', 'INPUT', 'SELECT']; if (!skipTags.includes(node.tagName)) { Array.from(node.childNodes).forEach(highlight); } } } highlight(document.body); // Re-highlight on dynamic content var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1 || node.nodeType === 3) highlight(node); }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Highlight Search Terms]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Strip utm_, fbclid, gclid, etc. from all links on page (function() { var trackingParams = ['utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'fbclid', 'gclid', 'dclid', 'msclkid', 'yclid', 'ref', 'ref_src', 'source', 'medium', 'campaign']; function cleanUrl(url) { try { var u = new URL(url, window.location.origin); var changed = false; trackingParams.forEach(function(p) { if (u.searchParams.has(p)) { u.searchParams.delete(p); changed = true; } }); return changed ? u.toString() : url; } catch (e) { return url; } } function cleanLinks() { document.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } cleanLinks(); var observer = new MutationObserver(function(mutations) { mutations.forEach(function(m) { m.addedNodes.forEach(function(node) { if (node.nodeType === 1) { if (node.tagName === 'A') cleanLinks(); node.querySelectorAll('a[href]').forEach(function(a) { var clean = cleanUrl(a.href); if (clean !== a.href) a.href = clean; }); } }); }); }); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:Remove Tracking Parameters from Links]', __e); } })(); (function(){ try { var __m = "youtube.com"; var __re = new RegExp('^' + "youtube\\.com" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Auto-enable theater mode on YouTube (function() { function tryTheater() { var btn = document.querySelector('button[aria-label="Theater mode"], ytd-player #player button[title="Theater mode"]'); if (btn && !btn.classList.contains('activated')) { btn.click(); } } // Try immediately tryTheater(); // Try after navigation (SPA) var lastUrl = location.href; setInterval(function() { if (location.href !== lastUrl) { lastUrl = location.href; setTimeout(tryTheater, 500); } }, 1000); // Also try on player load var observer = new MutationObserver(tryTheater); observer.observe(document.body, { childList: true, subtree: true }); })(); } } catch(__e) { console.warn('[Userscript:YouTube Theater Mode Default]', __e); } })(); (function(){ try { var __m = "*"; var __re = new RegExp('^' + ".*" + ', 'i'); if (__m === '*' || __re.test(location.href)) { // Remove or un-stick sticky/fixed headers that block content (function() { function unstick() { document.querySelectorAll('header, nav, [role="banner"], .header, .navbar, .sticky, .fixed-top, [style*="position: fixed"], [style*="position:sticky"]').forEach(function(el) { if (el.style.position === 'fixed' || el.style.position === 'sticky' || getComputedStyle(el).position === 'fixed' || getComputedStyle(el).position === 'sticky') { el.style.position = 'static'; el.style.top = 'auto'; el.style.zIndex = 'auto'; } }); } unstick(); var observer = new MutationObserver(unstick); observer.observe(document.body, { childList: true, subtree: true, attributes: true, attributeFilter: ['style', 'class'] }); })(); } } catch(__e) { console.warn('[Userscript:Kill Sticky Headers]', __e); } })(); })(); Fetch most dependencies via NPM by tinogo · Pull Request #377 · psolom/RichFilemanager · GitHub
Skip to content

Fetch most dependencies via NPM - #377

Open
tinogo wants to merge 9 commits into
psolom:masterfrom
tinogo:rework-dependencies
Open

Fetch most dependencies via NPM#377
tinogo wants to merge 9 commits into
psolom:masterfrom
tinogo:rework-dependencies

Conversation

@tinogo

@tinogotinogo commented Jan 29, 2019

Copy link
Copy Markdown

This MR will unversion most of the bundled libs (except those libs, which have some kind of customization...) and load them via NPM instead.

This makes it possible to considerably cut down the size of the dist package and this also works around a vulnerability of the jQuery-File-Upload plugin, as the PHP connector/adapter isn't versioned anymore! :)

I hope it haven't broke anything?! :)

@KevVerF

Copy link
Copy Markdown

I had some issues getting this to work:

  • src/scss/codemirror.scss => I had to remove the .css extension before grunt would include the actual content of the file
  • In the gruntfile I had to:
    • import node-sass "on top" => const sass = require('node-sass');
    • add "implementation" option => sass: { options: { implementation: sass } }
    • Disable the mangle option (it didn't check which dependency was out of scope) => uglify: { options: { mangle: false } }

I also updated packages.json, so that might be causing some of the above issues (especially in the gruntfile config)

{
"devDependencies": {
"grunt": "^1.0.4",
"grunt-contrib-concat": "^1.0.1",
"grunt-contrib-copy": "^1.0.0",
"grunt-contrib-cssmin": "^3.0.0",
"grunt-contrib-uglify": "^1.0.1",
"grunt-sass": "^3.0.2",
"node-sass": "^4.11.0",
"npm-run-all": "^4.0.2",
"uglify-js": "^3.0.27"
},
"dependencies": {
"@allmarkedup/purl": "git+https://github.com/allmarkedup/purl.git",
"blueimp-file-upload": "^9.12.1",
"blueimp-load-image": "^2.6.1",
"blueimp-tmpl": "^3.3.0",
"clipboard": "^2.0.4",
"codemirror": "^5.35.0",
"globalize": "^1.3.0",
"highlightjs": "^9.12.0",
"jquery": "^3.4.0",
"jquery-contextmenu": "^2.0.1",
"jquery-file-download": "^1.4.6",
"jquery-mousewheel": "^3.1.13",
"jquery-splitter": "git+https://github.com/GerHobbelt/splitter.git",
"knockout": "^3.4.0",
"malihu-custom-scrollbar-plugin": "^3.1.3",
"markdown-it": "^8.2.2",
"markdown-it-footnote": "^3.0.1",
"markdown-it-replace-link": "^1.0.0",
"pyrsmk-toast": "^2.2.0"
}
}

At first glance all seems to work for us.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@tinogo@KevVerF