Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions user.js/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ Tampermonkey is available from their homepage ([tampermonkey.net](https://www.ta

Each script has a matching `.meta.js` file for lightweight update checks.

Script versioning follows server format:

- `major.minor.bugfix.YYYYMMDD`

- `@updateURL` points to the script's `.meta.js` file
- `@downloadURL` points to the script's `.user.js` file
- `@supportURL` points to: `https://github.com/peeringdb/admincom/issues`
Expand All @@ -15,3 +19,26 @@ All update and download URLs use this base path:
- `https://raw.githubusercontent.com/peeringdb/admincom/master/user.js/`

Footnote: Scripts can be installed directly from GitHub _after_ [this script](https://github.com/jesus2099/konami-command/raw/master/INSTALL-USER-SCRIPT.user.js) has been installed.

## CP consolidation and migration

All legacy Control Panel (`peeringdb-cp-*`) scripts have been consolidated into one modular userscript:

- `peeringdb-cp-consolidated-tools.user.js`
- `peeringdb-cp-consolidated-tools.meta.js`

The consolidated script is scoped to `https://www.peeringdb.com/cp/peeringdb_server/*/*/change/*` and uses strict route guards so only relevant module behavior runs on matching pages.

### Legacy CP scripts

The following legacy CP scripts are now deprecation stubs and only log a console message pointing to the consolidated script:

- `peeringdb-cp-add-facility-address-search-to-google-maps.user.js`
- `peeringdb-cp-admin-console-set-link-target-blank-for-entity-website.user.js`
- `peeringdb-cp-control-panel-hightlight-dummy-organization-child-object.user.js`
- `peeringdb-cp-frontpage-link-on-admin-console.user.js`
- `peeringdb-cp-reset-all-network-information.user.js`
- `peeringdb-cp-search-user-e-mail-addresses-from-username.user.js`
- `peeringdb-cp-set-network-name-equal-to-organisation-name.user.js`

Each legacy `.meta.js` remains in place and version-synced to support update checks and explicit migration.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==UserScript==
// @name PeeringDB CP - Add facility address search to Google Maps
// @namespace https://www.peeringdb.com/cp/peeringdb_server/facility/
// @version 1.2.0.20260217
// @description Add a google maps link to the facility page
// @version 1.2.1.20260217
// @description DEPRECATED: replaced by PeeringDB CP - Consolidated Tools
// @author <chriztoffer@peeringdb.com>
// @include /^https:\/\/(\w+)\.peeringdb\.com\/cp\/peeringdb_server\/facility\/(\d+)\/change\/(.*)?
// @icon https://icons.duckduckgo.com/ip2/peeringdb.com.ico
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==UserScript==
// @name PeeringDB CP - Add facility address search to Google Maps
// @namespace https://www.peeringdb.com/cp/peeringdb_server/facility/
// @version 1.2.0.20260217
// @description Add a google maps link to the facility page
// @version 1.2.1.20260217
// @description DEPRECATED: replaced by PeeringDB CP - Consolidated Tools
// @author <chriztoffer@peeringdb.com>
// @include /^https:\/\/(\w+)\.peeringdb\.com\/cp\/peeringdb_server\/facility\/(\d+)\/change\/(.*)?
// @icon https://icons.duckduckgo.com/ip2/peeringdb.com.ico
Expand All @@ -14,42 +14,5 @@

(function() {
'use strict';

let padLeft = 459;
let linkText = 'Google Maps';

// Google Maps link
let maps = 'https://www.google.com/maps?q=';

// Get all the necessary address information fields from the current facility page
let address1 = document.querySelector('#id_address1').getAttribute('value');
let address2 = document.querySelector('#id_address2').getAttribute('value');
let city = document.querySelector('#id_city').getAttribute('value');
let state = document.querySelector('#id_state').getAttribute('value');
let zipcode = document.querySelector('#id_zipcode').getAttribute('value');
// The country code is only available as alpha-3166
let country = document.querySelector('#id_country > option[selected]').getAttribute('value');
let latitude = document.querySelector('#id_latitude').getAttribute('value');
let longtitude = document.querySelector('#id_longitude').getAttribute('value');

// Construct the HREF and URL encode the query string appended
// to the google maps link.
//
// We default to using lat,long for the query. If these values are
// not present. We default to encoding the address as a fallback.
let query = encodeURIComponent(
(latitude && longtitude) ? latitude + ',' + longtitude : ((address1) ? address1 : '') + ((city) ? '+' + city : '') + ((state) ? '+' + state : '') + ((zipcode) ? '+' + zipcode : '') + ((country) ? '+' + country : '')
);

let link = maps + query;

const childNode = document.createElement('ul');
const parentNode = document.querySelector('#grp-content-title > ul').parentNode;

childNode.innerHTML += '<li class="grp-object-tools" style="padding-right:' + padLeft + 'px;">' + '<a href="' + link + '" target="' + encodeURIComponent(query) + '">' + linkText + '</a>' + '</li>';

let sp2 = document.querySelector('#grp-content-title > ul');
parentNode.insertBefore(childNode, sp2);

console.log(link);
console.warn('[Deprecated] PeeringDB CP - Add facility address search to Google Maps has been replaced by PeeringDB CP - Consolidated Tools (install: peeringdb-cp-consolidated-tools.user.js).');
})();
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==UserScript==
// @name PeeringDB CP - Admin Console set link target BLANK for entity website
// @namespace https://www.peeringdb.com/cp/
// @version 1.1.0.20260217
// @description Set the link target. Forcing clinking on the link to open a new tab.
// @version 1.1.1.20260217
// @description DEPRECATED: replaced by PeeringDB CP - Consolidated Tools
// @author <chriztoffer@peeringdb.com>
// @include /^https:\/\/(\w+)\.peeringdb\.com\/cp\/peeringdb_server\/(facility|network|organization|carrier|internetexchange|campus)\/(\d+)\/change\/(.*)?
// @icon https://icons.duckduckgo.com/ip2/peeringdb.com.ico
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// ==UserScript==
// @name PeeringDB CP - Admin Console set link target BLANK for entity website
// @namespace https://www.peeringdb.com/cp/
// @version 1.1.0.20260217
// @description Set the link target. Forcing clinking on the link to open a new tab.
// @version 1.1.1.20260217
// @description DEPRECATED: replaced by PeeringDB CP - Consolidated Tools
// @author <chriztoffer@peeringdb.com>
// @include /^https:\/\/(\w+)\.peeringdb\.com\/cp\/peeringdb_server\/(facility|network|organization|carrier|internetexchange|campus)\/(\d+)\/change\/(.*)?
// @icon https://icons.duckduckgo.com/ip2/peeringdb.com.ico
Expand All @@ -14,12 +14,6 @@

(function() {
'use strict';

let path = window.location.pathname.replace(/(^\/|\/$)/g, '').split('/');
let type = path[2];
let id = path[3];

// overwrite link target to new tab
document.querySelector('.website > div > div > p > a').target = 'peeringdb_' + type + '_' + id;
console.warn('[Deprecated] PeeringDB CP - Admin Console set link target BLANK for entity website has been replaced by PeeringDB CP - Consolidated Tools (install: peeringdb-cp-consolidated-tools.user.js).');

})();
13 changes: 13 additions & 0 deletions user.js/peeringdb-cp-consolidated-tools.meta.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
// ==UserScript==
// @name PeeringDB CP - Consolidated Tools
// @namespace https://www.peeringdb.com/cp/
// @version 1.0.9.20260223
// @description Consolidated CP userscript with strict route-isolated modules for facility/network/user/entity workflows
// @author <chriztoffer@peeringdb.com>
// @match https://www.peeringdb.com/cp/peeringdb_server/*/*/change/*
// @icon https://icons.duckduckgo.com/ip2/peeringdb.com.ico
// @grant GM_xmlhttpRequest
// @updateURL https://raw.githubusercontent.com/peeringdb/admincom/master/user.js/peeringdb-cp-consolidated-tools.meta.js
// @downloadURL https://raw.githubusercontent.com/peeringdb/admincom/master/user.js/peeringdb-cp-consolidated-tools.user.js
// @supportURL https://github.com/peeringdb/admincom/issues
// ==/UserScript==
Loading